<!doctype html><html lang="en">
 <head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <title>Selectors Level 4</title>
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <meta content="refining" name="csswg-work-status">
  <meta content="ED" name="w3c-status">
  <meta content="<a>Selectors</a> are patterns that match against elements in a tree, and as such form one of several technologies that can be used to select nodes in a document. Selectors have been optimized for use with HTML and XML, and are designed to be usable in performance-critical code. They are a core component of <abbr title=&quot;Cascading Style Sheets&quot;>CSS</abbr> (Cascading Style Sheets), which uses Selectors to bind style properties to elements in the docu	ment.  Selectors Level 4 describes the selectors that already exist in [[!SELECT]], and further introduces new selectors for CSS and other languages that may need them." name="abstract">
  <link href="../default.css" rel="stylesheet" type="text/css">
  <link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
  body {
    background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat;
  }
  </style>
  <link href="https://www.w3.org/TR/selectors-4/" rel="canonical">
<script defer src="https://test.csswg.org/harness/annotate.js#!selectors-4_dev/selectors-4" type="text/javascript"></script>
<style>
#selector-examples td:first-child {
	white-space: nowrap;
}
</style>
<style>/* style-md-lists */

/* This is a weird hack for me not yet following the commonmark spec
   regarding paragraph and lists. */
[data-md] > :first-child {
    margin-top: 0;
}
[data-md] > :last-child {
    margin-bottom: 0;
}</style>
<style>/* style-selflinks */

.heading, .issue, .note, .example, li, dt {
    position: relative;
}
a.self-link {
    position: absolute;
    top: 0;
    left: calc(-1 * (3.5rem - 26px));
    width: calc(3.5rem - 26px);
    height: 2em;
    text-align: center;
    border: none;
    transition: opacity .2s;
    opacity: .5;
}
a.self-link:hover {
    opacity: 1;
}
.heading > a.self-link {
    font-size: 83%;
}
li > a.self-link {
    left: calc(-1 * (3.5rem - 26px) - 2em);
}
dfn > a.self-link {
    top: auto;
    left: auto;
    opacity: 0;
    width: 1.5em;
    height: 1.5em;
    background: gray;
    color: white;
    font-style: normal;
    transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
    opacity: 1;
}
dfn > a.self-link:hover {
    color: black;
}

a.self-link::before            { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before      { content: "#"; }</style>
<style>/* style-counters */

body {
    counter-reset: example figure issue;
}
.issue {
    counter-increment: issue;
}
.issue:not(.no-marker)::before {
    content: "Issue " counter(issue);
}

.example {
    counter-increment: example;
}
.example:not(.no-marker)::before {
    content: "Example " counter(example);
}
.invalid.example:not(.no-marker)::before,
.illegal.example:not(.no-marker)::before {
    content: "Invalid Example" counter(example);
}

figcaption {
    counter-increment: figure;
}
figcaption:not(.no-marker)::before {
    content: "Figure " counter(figure) " ";
}</style>
<style>/* style-var-click-highlighting */

    var { cursor: pointer; }
    var.selected0 { background-color: #F4D200; box-shadow: 0 0 0 2px #F4D200; }
    var.selected1 { background-color: #FF87A2; box-shadow: 0 0 0 2px #FF87A2; }
    var.selected2 { background-color: #96E885; box-shadow: 0 0 0 2px #96E885; }
    var.selected3 { background-color: #3EEED2; box-shadow: 0 0 0 2px #3EEED2; }
    var.selected4 { background-color: #EACFB6; box-shadow: 0 0 0 2px #EACFB6; }
    var.selected5 { background-color: #82DDFF; box-shadow: 0 0 0 2px #82DDFF; }
    var.selected6 { background-color: #FFBCF2; box-shadow: 0 0 0 2px #FFBCF2; }
    </style>
<style>/* style-autolinks */

.css.css, .property.property, .descriptor.descriptor {
    color: #005a9c;
    font-size: inherit;
    font-family: inherit;
}
.css::before, .property::before, .descriptor::before {
    content: "‘";
}
.css::after, .property::after, .descriptor::after {
    content: "’";
}
.property, .descriptor {
    /* Don't wrap property and descriptor names */
    white-space: nowrap;
}
.type { /* CSS value <type> */
    font-style: italic;
}
pre .property::before, pre .property::after {
    content: "";
}
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {
    content: "‘";
}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {
    content: "’";
}

[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after {
    content: "";
}

[data-link-type=element],
[data-link-type=element-attr] {
    font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
    font-size: .9em;
}
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after  { content: ">" }

[data-link-type=biblio] {
    white-space: pre;
}</style>
<style>/* style-dfn-panel */

.dfn-panel {
    position: absolute;
    z-index: 35;
    height: auto;
    width: -webkit-fit-content;
    width: fit-content;
    max-width: 300px;
    max-height: 500px;
    overflow: auto;
    padding: 0.5em 0.75em;
    font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
    background: #DDDDDD;
    color: black;
    border: outset 0.2em;
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: black; }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0; }
.dfn-panel li { list-style: inside; }
.dfn-panel.activated {
    display: inline-block;
    position: fixed;
    left: .5em;
    bottom: 2em;
    margin: 0 auto;
    max-width: calc(100vw - 1.5em - .4em - .5em);
    max-height: 30vh;
}

.dfn-paneled { cursor: pointer; }
</style>
<style>/* style-syntax-highlighting */

.highlight:not(.idl) { background: hsl(24, 20%, 95%); }
code.highlight { padding: .1em; border-radius: .3em; }
pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; }
c-[a] { color: #990055 } /* Keyword.Declaration */
c-[b] { color: #990055 } /* Keyword.Type */
c-[c] { color: #708090 } /* Comment */
c-[d] { color: #708090 } /* Comment.Multiline */
c-[e] { color: #0077aa } /* Name.Attribute */
c-[f] { color: #669900 } /* Name.Tag */
c-[g] { color: #222222 } /* Name.Variable */
c-[k] { color: #990055 } /* Keyword */
c-[l] { color: #000000 } /* Literal */
c-[m] { color: #000000 } /* Literal.Number */
c-[n] { color: #0077aa } /* Name */
c-[o] { color: #999999 } /* Operator */
c-[p] { color: #999999 } /* Punctuation */
c-[s] { color: #a67f59 } /* Literal.String */
c-[t] { color: #a67f59 } /* Literal.String.Single */
c-[u] { color: #a67f59 } /* Literal.String.Double */
c-[cp] { color: #708090 } /* Comment.Preproc */
c-[c1] { color: #708090 } /* Comment.Single */
c-[cs] { color: #708090 } /* Comment.Special */
c-[kc] { color: #990055 } /* Keyword.Constant */
c-[kn] { color: #990055 } /* Keyword.Namespace */
c-[kp] { color: #990055 } /* Keyword.Pseudo */
c-[kr] { color: #990055 } /* Keyword.Reserved */
c-[ld] { color: #000000 } /* Literal.Date */
c-[nc] { color: #0077aa } /* Name.Class */
c-[no] { color: #0077aa } /* Name.Constant */
c-[nd] { color: #0077aa } /* Name.Decorator */
c-[ni] { color: #0077aa } /* Name.Entity */
c-[ne] { color: #0077aa } /* Name.Exception */
c-[nf] { color: #0077aa } /* Name.Function */
c-[nl] { color: #0077aa } /* Name.Label */
c-[nn] { color: #0077aa } /* Name.Namespace */
c-[py] { color: #0077aa } /* Name.Property */
c-[ow] { color: #999999 } /* Operator.Word */
c-[mb] { color: #000000 } /* Literal.Number.Bin */
c-[mf] { color: #000000 } /* Literal.Number.Float */
c-[mh] { color: #000000 } /* Literal.Number.Hex */
c-[mi] { color: #000000 } /* Literal.Number.Integer */
c-[mo] { color: #000000 } /* Literal.Number.Oct */
c-[sb] { color: #a67f59 } /* Literal.String.Backtick */
c-[sc] { color: #a67f59 } /* Literal.String.Char */
c-[sd] { color: #a67f59 } /* Literal.String.Doc */
c-[se] { color: #a67f59 } /* Literal.String.Escape */
c-[sh] { color: #a67f59 } /* Literal.String.Heredoc */
c-[si] { color: #a67f59 } /* Literal.String.Interpol */
c-[sx] { color: #a67f59 } /* Literal.String.Other */
c-[sr] { color: #a67f59 } /* Literal.String.Regex */
c-[ss] { color: #a67f59 } /* Literal.String.Symbol */
c-[vc] { color: #0077aa } /* Name.Variable.Class */
c-[vg] { color: #0077aa } /* Name.Variable.Global */
c-[vi] { color: #0077aa } /* Name.Variable.Instance */
c-[il] { color: #000000 } /* Literal.Number.Integer.Long */
</style>
 <body class="h-entry">
  <div class="head">
   <p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C" width="72"> </a> </p>
   <h1 class="p-name no-ref" id="title">Selectors Level 4</h1>
   <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="1970-01-01">1 January 1970</time></span></h2>
   <details>
    <summary>Specification Metadata</summary>
    <div data-fill-with="spec-metadata">
     <dl>
      <dt>This version:
      <dd><a class="u-url" href="https://drafts.csswg.org/selectors/">https://drafts.csswg.org/selectors/</a>
      <dt>Latest published version:
      <dd><a href="https://www.w3.org/TR/selectors-4/">https://www.w3.org/TR/selectors-4/</a>
      <dt>Previous Versions:
      <dd><a href="https://www.w3.org/TR/2018/WD-selectors-4-20180202/" rel="prev">https://www.w3.org/TR/2018/WD-selectors-4-20180202/</a>
      <dd><a href="https://www.w3.org/TR/2018/WD-selectors-4-20180201/" rel="prev">https://www.w3.org/TR/2018/WD-selectors-4-20180201/</a>
      <dd><a href="https://www.w3.org/TR/2013/WD-selectors4-20130502/" rel="prev">https://www.w3.org/TR/2013/WD-selectors4-20130502/</a>
      <dd><a href="https://www.w3.org/TR/2012/WD-selectors4-20120823/" rel="prev">https://www.w3.org/TR/2012/WD-selectors4-20120823/</a>
      <dd><a href="https://www.w3.org/TR/2011/WD-selectors4-20110929/" rel="prev">https://www.w3.org/TR/2011/WD-selectors4-20110929/</a>
      <dt>Test Suite:
      <dd><a href="http://test.csswg.org/suites/selectors-4_dev/nightly-unstable/">http://test.csswg.org/suites/selectors-4_dev/nightly-unstable/</a>
      <dt class="editor">Editors:
      <dd class="editor p-author h-card vcard" data-editor-id="35400"><a class="p-name fn u-url url" href="http://fantasai.inkedblade.net/contact">Elika J. Etemad / fantasai</a> (<span class="p-org org">Invited Expert</span>)
      <dd class="editor p-author h-card vcard" data-editor-id="42199"><a class="p-name fn u-url url" href="http://xanthir.com/contact/">Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)
      <dt class="editor">Former Editors:
      <dd class="editor p-author h-card vcard"><a class="p-name fn u-url url" href="http://www.tantek.com">Tantek Çelik</a>
      <dd class="editor p-author h-card vcard"><span class="p-name fn">Daniel Glazman</span>
      <dd class="editor p-author h-card vcard"><span class="p-name fn">Ian Hickson</span>
      <dd class="editor p-author h-card vcard"><span class="p-name fn">Peter Linss</span>
      <dd class="editor p-author h-card vcard"><span class="p-name fn">John Williams</span>
      <dt>Suggest an Edit for this Spec:
      <dd><a href="https://github.com/w3c/csswg-drafts/blob/master/selectors-4/Overview.bs">GitHub Editor</a>
      <dt>Issue Tracking:
      <dd><a href="https://github.com/w3c/csswg-drafts/labels/selectors-4">GitHub Issues</a>
     </dl>
    </div>
   </details>
   <div data-fill-with="warning"></div>
   <p class="copyright" data-fill-with="copyright"><a href="https://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 1970 <a href="https://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="https://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="https://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="https://www.keio.ac.jp/">Keio</a>, <a href="https://ev.buaa.edu.cn/">Beihang</a>). W3C <a href="https://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document">permissive document license</a> rules apply. </p>
   <hr title="Separator for header">
  </div>
  <div class="p-summary" data-fill-with="abstract">
   <h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
   <p><a data-link-type="dfn" href="#selector" id="ref-for-selector">Selectors</a> are patterns that match against elements in a tree, and as such form one of several technologies that can be used to select nodes in a document. Selectors have been optimized for use with HTML and XML, and are designed to be usable in performance-critical code. They are a core component of <abbr title="Cascading Style Sheets">CSS</abbr> (Cascading Style Sheets), which uses Selectors to bind style properties to elements in the docu	ment.

Selectors Level 4 describes the selectors that already exist in <a data-link-type="biblio" href="#biblio-select">[SELECT]</a>, and further introduces new selectors for CSS and other languages that may need them.</p>
    <a href="https://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, etc. 
  </div>
  <h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
  <div data-fill-with="status">
   <p> This is a public copy of the editors’ draft.
	It is provided for discussion only and may change at any moment.
	Its publication here does not imply endorsement of its contents by W3C.
	Don’t cite this document other than as work in progress. </p>
   <p> <a href="https://github.com/w3c/csswg-drafts/issues">GitHub Issues</a> are preferred for discussion of this specification.
	When filing an issue, please put the text “selectors” in the title,
	preferably like this:
	“[selectors] <i data-lt>…summary of comment…</i>”.
	All issues and comments are <a href="https://lists.w3.org/Archives/Public/public-css-archive/">archived</a>,
	and there is also a <a href="https://lists.w3.org/Archives/Public/www-style/">historical archive</a>. </p>
   <p> This document was produced by the <a href="https://www.w3.org/Style/CSS/">CSS Working Group</a>. </p>
   <p> This document was produced by a group operating under
	the <a href="https://www.w3.org/Consortium/Patent-Policy/">W3C Patent Policy</a>.
	W3C maintains a <a href="https://www.w3.org/2004/01/pp-impl/32061/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group;
	that page also includes instructions for disclosing a patent.
	An individual who has actual knowledge of a patent which the individual believes contains <a href="https://www.w3.org/Consortium/Patent-Policy/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="https://www.w3.org/Consortium/Patent-Policy/#sec-Disclosure">section 6 of the W3C Patent Policy</a>. </p>
   <p> This document is governed by the <a href="https://www.w3.org/2019/Process-20190301/" id="w3c_process_revision">1 March 2019 W3C Process Document</a>. </p>
   <p></p>
  </div>
  <div data-fill-with="at-risk">
   <p>The following features are at-risk, and may be dropped during the CR period: </p>
   <ul>
    <li>the column combinator
    <li>the <a class="css" data-link-type="maybe" href="#read-write-pseudo" id="ref-for-read-write-pseudo">:read-write</a> pseudo-class
   </ul>
   <p>“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulty being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.</p>
  </div>
  <nav data-fill-with="table-of-contents" id="toc">
   <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
   <ol class="toc" role="directory">
    <li>
     <a href="#context"><span class="secno">1</span> <span class="content"> Introduction</span></a>
     <ol class="toc">
      <li><a href="#placement"><span class="secno">1.1</span> <span class="content">Module Interactions</span></a>
     </ol>
    <li>
     <a href="#overview"><span class="secno">2</span> <span class="content"> Selectors Overview</span></a>
     <ol class="toc">
      <li><a href="#profiles"><span class="secno">2.1</span> <span class="content"> <span>Live</span> vs <span>Snapshot</span> Selector Profiles</span></a>
     </ol>
    <li>
     <a href="#syntax"><span class="secno">3</span> <span class="content"> Selector Syntax and Structure</span></a>
     <ol class="toc">
      <li><a href="#structure"><span class="secno">3.1</span> <span class="content"> Structure and Terminology</span></a>
      <li><a href="#data-model"><span class="secno">3.2</span> <span class="content"> Data Model</span></a>
      <li><a href="#scoping"><span class="secno">3.3</span> <span class="content"> Scoped Selectors</span></a>
      <li>
       <a href="#relative"><span class="secno">3.4</span> <span class="content"> Relative Selectors</span></a>
       <ol class="toc">
        <li><a href="#absolutizing"><span class="secno">3.4.1</span> <span class="content"> Absolutizing a Relative Selector</span></a>
       </ol>
      <li><a href="#pseudo-classes"><span class="secno">3.5</span> <span class="content"> Pseudo-classes</span></a>
      <li>
       <a href="#pseudo-elements"><span class="secno">3.6</span> <span class="content">Pseudo-elements</span></a>
       <ol class="toc">
        <li><a href="#pseudo-element-syntax"><span class="secno">3.6.1</span> <span class="content"> Syntax</span></a>
        <li><a href="#pseudo-element-attachment"><span class="secno">3.6.2</span> <span class="content"> Binding to the Document Tree</span></a>
        <li><a href="#pseudo-element-states"><span class="secno">3.6.3</span> <span class="content"> Pseudo-classing Pseudo-elements</span></a>
        <li><a href="#pseudo-element-structure"><span class="secno">3.6.4</span> <span class="content"> Internal Structure</span></a>
       </ol>
      <li><a href="#case-sensitive"><span class="secno">3.7</span> <span class="content"> Characters and case sensitivity</span></a>
      <li><a href="#namespaces"><span class="secno">3.8</span> <span class="content"> Declaring Namespace Prefixes</span></a>
      <li><a href="#invalid"><span class="secno">3.9</span> <span class="content"> Invalid Selectors and Error Handling</span></a>
     </ol>
    <li>
     <a href="#logical-combination"><span class="secno">4</span> <span class="content"> Logical Combinations</span></a>
     <ol class="toc">
      <li><a href="#grouping"><span class="secno">4.1</span> <span class="content"> Selector Lists</span></a>
      <li><a href="#matches"><span class="secno">4.2</span> <span class="content"> The Matches-Any Pseudo-class: <span class="css">:is()</span></span></a>
      <li><a href="#negation"><span class="secno">4.3</span> <span class="content"> The Negation (Matches-None) Pseudo-class: <span class="css">:not()</span></span></a>
      <li><a href="#zero-matches"><span class="secno">4.4</span> <span class="content"> The Specificity-adjustment Pseudo-class: <span class="css">:where()</span></span></a>
      <li><a href="#relational"><span class="secno">4.5</span> <span class="content"> The Relational Pseudo-class: <span class="css">:has()</span></span></a>
     </ol>
    <li>
     <a href="#elemental-selectors"><span class="secno">5</span> <span class="content"> Elemental selectors</span></a>
     <ol class="toc">
      <li><a href="#type-selectors"><span class="secno">5.1</span> <span class="content"> Type (tag name) selector</span></a>
      <li><a href="#the-universal-selector"><span class="secno">5.2</span> <span class="content"> Universal selector </span></a>
      <li><a href="#type-nmsp"><span class="secno">5.3</span> <span class="content"> Namespaces in Elemental Selectors</span></a>
     </ol>
    <li>
     <a href="#attribute-selectors"><span class="secno">6</span> <span class="content"> Attribute selectors</span></a>
     <ol class="toc">
      <li><a href="#attribute-representation"><span class="secno">6.1</span> <span class="content"> Attribute presence and value selectors</span></a>
      <li><a href="#attribute-substrings"><span class="secno">6.2</span> <span class="content"> Substring matching attribute selectors</span></a>
      <li><a href="#attribute-case"><span class="secno">6.3</span> <span class="content"> Case-sensitivity</span></a>
      <li><a href="#attrnmsp"><span class="secno">6.4</span> <span class="content"> Attribute selectors and namespaces</span></a>
      <li><a href="#def-values"><span class="secno">6.5</span> <span class="content"> Default attribute values in DTDs</span></a>
      <li><a href="#class-html"><span class="secno">6.6</span> <span class="content"> Class selectors</span></a>
      <li><a href="#id-selectors"><span class="secno">6.7</span> <span class="content"> ID selectors</span></a>
     </ol>
    <li>
     <a href="#linguistic-pseudos"><span class="secno">7</span> <span class="content"> Linguistic Pseudo-classes</span></a>
     <ol class="toc">
      <li><a href="#the-dir-pseudo"><span class="secno">7.1</span> <span class="content"> The Directionality Pseudo-class: <span class="css">:dir()</span></span></a>
      <li><a href="#the-lang-pseudo"><span class="secno">7.2</span> <span class="content"> The Language Pseudo-class: <span class="css">:lang()</span></span></a>
     </ol>
    <li>
     <a href="#location"><span class="secno">8</span> <span class="content"> Location Pseudo-classes</span></a>
     <ol class="toc">
      <li><a href="#the-any-link-pseudo"><span class="secno">8.1</span> <span class="content"> The Hyperlink Pseudo-class: <span class="css">:any-link</span></span></a>
      <li><a href="#link"><span class="secno">8.2</span> <span class="content"> The Link History Pseudo-classes: <span class="css">:link</span> and <span class="css">:visited</span></span></a>
      <li><a href="#the-local-link-pseudo"><span class="secno">8.3</span> <span class="content"> The Local Link Pseudo-class: <span class="css">:local-link</span></span></a>
      <li><a href="#the-target-pseudo"><span class="secno">8.4</span> <span class="content"> The Target Pseudo-class: <span class="css">:target</span></span></a>
      <li><a href="#the-target-within-pseudo"><span class="secno">8.5</span> <span class="content"> The Target Container Pseudo-class: <span class="css">:target-within</span></span></a>
      <li><a href="#the-scope-pseudo"><span class="secno">8.6</span> <span class="content"> The Reference Element Pseudo-class: <span class="css">:scope</span></span></a>
     </ol>
    <li>
     <a href="#useraction-pseudos"><span class="secno">9</span> <span class="content"> User Action Pseudo-classes</span></a>
     <ol class="toc">
      <li><a href="#the-hover-pseudo"><span class="secno">9.1</span> <span class="content"> The Pointer Hover Pseudo-class: <span class="css">:hover</span></span></a>
      <li><a href="#the-active-pseudo"><span class="secno">9.2</span> <span class="content"> The Activation Pseudo-class: <span class="css">:active</span></span></a>
      <li><a href="#the-focus-pseudo"><span class="secno">9.3</span> <span class="content"> The Input Focus Pseudo-class: <span class="css">:focus</span></span></a>
      <li><a href="#the-focus-visible-pseudo"><span class="secno">9.4</span> <span class="content"> The Focus-Indicated Pseudo-class: <span class="css">:focus-visible</span></span></a>
      <li><a href="#the-focus-within-pseudo"><span class="secno">9.5</span> <span class="content"> The Focus Container Pseudo-class: <span class="css">:focus-within</span></span></a>
     </ol>
    <li>
     <a href="#time-pseudos"><span class="secno">10</span> <span class="content"> Time-dimensional Pseudo-classes</span></a>
     <ol class="toc">
      <li><a href="#the-current-pseudo"><span class="secno">10.1</span> <span class="content"> The Current-element Pseudo-class: <span class="css">:current</span></span></a>
      <li><a href="#the-past-pseudo"><span class="secno">10.2</span> <span class="content"> The Past-element Pseudo-class: <span class="css">:past</span></span></a>
      <li><a href="#the-future-pseudo"><span class="secno">10.3</span> <span class="content"> The Future-element Pseudo-class: <span class="css">:future</span></span></a>
     </ol>
    <li>
     <a href="#resource-pseudos"><span class="secno">11</span> <span class="content"> Resource State Pseudos</span></a>
     <ol class="toc">
      <li><a href="#video-state"><span class="secno">11.1</span> <span class="content"> Video/Audio Play State: the <span class="css">:playing</span> and <span class="css">:paused</span> pseudo-classes</span></a>
     </ol>
    <li>
     <a href="#input-pseudos"><span class="secno">12</span> <span class="content"> The Input Pseudo-classes</span></a>
     <ol class="toc">
      <li>
       <a href="#input-states"><span class="secno">12.1</span> <span class="content"> Input Control States</span></a>
       <ol class="toc">
        <li><a href="#enableddisabled"><span class="secno">12.1.1</span> <span class="content"> The <span class="css">:enabled</span> and <span class="css">:disabled</span> Pseudo-classes</span></a>
        <li><a href="#rw-pseudos"><span class="secno">12.1.2</span> <span class="content"> The Mutability Pseudo-classes: <span class="css">:read-only</span> and <span class="css">:read-write</span></span></a>
        <li><a href="#placeholder"><span class="secno">12.1.3</span> <span class="content"> The Placeholder-shown Pseudo-class: <span class="css">:placeholder-shown</span></span></a>
        <li><a href="#the-default-pseudo"><span class="secno">12.1.4</span> <span class="content"> The Default-option Pseudo-class: <span class="css">:default</span></span></a>
       </ol>
      <li>
       <a href="#input-value-states"><span class="secno">12.2</span> <span class="content"> Input Value States</span></a>
       <ol class="toc">
        <li><a href="#checked"><span class="secno">12.2.1</span> <span class="content"> The Selected-option Pseudo-class: <span class="css">:checked</span></span></a>
        <li><a href="#indeterminate"><span class="secno">12.2.2</span> <span class="content"> The Indeterminate-value Pseudo-class: <span class="css">:indeterminate</span></span></a>
       </ol>
      <li>
       <a href="#ui-validity"><span class="secno">12.3</span> <span class="content"> Input Value-checking</span></a>
       <ol class="toc">
        <li><a href="#blank"><span class="secno">12.3.1</span> <span class="content"> The Empty-Value Pseudo-class: <span class="css">:blank</span></span></a>
        <li><a href="#validity-pseudos"><span class="secno">12.3.2</span> <span class="content"> The Validity Pseudo-classes: <span class="css">:valid</span> and <span class="css">:invalid</span></span></a>
        <li><a href="#range-pseudos"><span class="secno">12.3.3</span> <span class="content"> The Range Pseudo-classes: <span class="css">:in-range</span> and <span class="css">:out-of-range</span></span></a>
        <li><a href="#opt-pseudos"><span class="secno">12.3.4</span> <span class="content"> The Optionality Pseudo-classes: <span class="css">:required</span> and <span class="css">:optional</span></span></a>
        <li><a href="#user-pseudos"><span class="secno">12.3.5</span> <span class="content"> The User-interaction Pseudo-class: <span class="css">:user-invalid</span></span></a>
       </ol>
     </ol>
    <li>
     <a href="#structural-pseudos"><span class="secno">13</span> <span class="content"> Tree-Structural pseudo-classes</span></a>
     <ol class="toc">
      <li><a href="#the-root-pseudo"><span class="secno">13.1</span> <span class="content"> <span class="css">:root</span> pseudo-class</span></a>
      <li><a href="#the-empty-pseudo"><span class="secno">13.2</span> <span class="content"> <span class="css">:empty</span> pseudo-class</span></a>
      <li>
       <a href="#child-index"><span class="secno">13.3</span> <span class="content"> Child-indexed Pseudo-classes</span></a>
       <ol class="toc">
        <li><a href="#the-nth-child-pseudo"><span class="secno">13.3.1</span> <span class="content"> <span class="css">:nth-child()</span> pseudo-class</span></a>
        <li><a href="#the-nth-last-child-pseudo"><span class="secno">13.3.2</span> <span class="content"> <span class="css">:nth-last-child()</span> pseudo-class</span></a>
        <li><a href="#the-first-child-pseudo"><span class="secno">13.3.3</span> <span class="content"> <span class="css">:first-child</span> pseudo-class</span></a>
        <li><a href="#the-last-child-pseudo"><span class="secno">13.3.4</span> <span class="content"> <span class="css">:last-child</span> pseudo-class</span></a>
        <li><a href="#the-only-child-pseudo"><span class="secno">13.3.5</span> <span class="content"> <span class="css">:only-child</span> pseudo-class</span></a>
       </ol>
      <li>
       <a href="#typed-child-index"><span class="secno">13.4</span> <span class="content"> Typed Child-indexed Pseudo-classes</span></a>
       <ol class="toc">
        <li><a href="#the-nth-of-type-pseudo"><span class="secno">13.4.1</span> <span class="content"> <span class="css">:nth-of-type()</span> pseudo-class</span></a>
        <li><a href="#the-nth-last-of-type-pseudo"><span class="secno">13.4.2</span> <span class="content"> <span class="css">:nth-last-of-type()</span> pseudo-class</span></a>
        <li><a href="#the-first-of-type-pseudo"><span class="secno">13.4.3</span> <span class="content"> <span class="css">:first-of-type</span> pseudo-class</span></a>
        <li><a href="#the-last-of-type-pseudo"><span class="secno">13.4.4</span> <span class="content"> <span class="css">:last-of-type</span> pseudo-class</span></a>
        <li><a href="#the-only-of-type-pseudo"><span class="secno">13.4.5</span> <span class="content"> <span class="css">:only-of-type</span> pseudo-class</span></a>
       </ol>
     </ol>
    <li>
     <a href="#combinators"><span class="secno">14</span> <span class="content"> Combinators</span></a>
     <ol class="toc">
      <li><a href="#descendant-combinators"><span class="secno">14.1</span> <span class="content"> Descendant combinator (<code> </code>)</span></a>
      <li><a href="#child-combinators"><span class="secno">14.2</span> <span class="content"> Child combinator (<code>></code>)</span></a>
      <li><a href="#adjacent-sibling-combinators"><span class="secno">14.3</span> <span class="content"> Next-sibling combinator (<code>+</code>)</span></a>
      <li><a href="#general-sibling-combinators"><span class="secno">14.4</span> <span class="content"> Subsequent-sibling combinator (<code>~</code>)</span></a>
     </ol>
    <li>
     <a href="#table-pseudos"><span class="secno">15</span> <span class="content"> Grid-Structural Selectors</span></a>
     <ol class="toc">
      <li><a href="#the-column-combinator"><span class="secno">15.1</span> <span class="content"> Column combinator (<code>||</code>)</span></a>
      <li><a href="#the-nth-col-pseudo"><span class="secno">15.2</span> <span class="content"> <span class="css">:nth-col()</span> pseudo-class</span></a>
      <li><a href="#the-nth-last-col-pseudo"><span class="secno">15.3</span> <span class="content"> <span class="css">:nth-last-col()</span> pseudo-class</span></a>
     </ol>
    <li><a href="#specificity-rules"><span class="secno">16</span> <span class="content"> Calculating a selector’s specificity</span></a>
    <li><a href="#grammar"><span class="secno">17</span> <span class="content"> Grammar</span></a>
    <li>
     <a href="#api-hooks"><span class="secno">18</span> <span class="content"> API Hooks</span></a>
     <ol class="toc">
      <li><a href="#parse-selector"><span class="secno">18.1</span> <span class="content"> Parse A Selector</span></a>
      <li><a href="#parse-relative-selector"><span class="secno">18.2</span> <span class="content"> Parse A Relative Selector</span></a>
      <li><a href="#match-against-element"><span class="secno">18.3</span> <span class="content"> Match a Selector Against an Element</span></a>
      <li><a href="#match-against-pseudo-element"><span class="secno">18.4</span> <span class="content"> Match a Selector Against a Pseudo-element</span></a>
      <li><a href="#match-against-tree"><span class="secno">18.5</span> <span class="content"> Match a Selector Against a Tree</span></a>
     </ol>
    <li><a href="#dom-mapping"><span class="secno">19</span> <span class="content"> Appendix A: Guidance on Mapping Source Documents &amp; Data to an Element Tree</span></a>
    <li><a href="#compat"><span class="secno">20</span> <span class="content"> Appendix B: Obsolete but Required Parsing Quirks for Web Compat</span></a>
    <li>
     <a href="#changes"><span class="secno">21</span> <span class="content"> Changes</span></a>
     <ol class="toc">
      <li><a href="#changes-2018-02"><span class="secno">21.1</span> <span class="content"> Changes since the 2 February 2018 Working Draft</span></a>
      <li><a href="#changes-2013"><span class="secno">21.2</span> <span class="content"> Changes since the 2 May 2013 Working Draft</span></a>
      <li><a href="#changes-2012"><span class="secno">21.3</span> <span class="content"> Changes since the 23 August 2012 Working Draft</span></a>
      <li><a href="#changes-2011"><span class="secno">21.4</span> <span class="content"> Changes since the 29 September 2011 Working Draft</span></a>
      <li><a href="#changes-level-3"><span class="secno">21.5</span> <span class="content"> Changes Since Level 3</span></a>
     </ol>
    <li><a href="#acknowledgements"><span class="secno">22</span> <span class="content"> Acknowledgements</span></a>
    <li><a href="#priv-sec"><span class="secno">23</span> <span class="content">Privacy and Security Considerations</span></a>
    <li>
     <a href="#conformance"><span class="secno"></span> <span class="content"> Conformance</span></a>
     <ol class="toc">
      <li><a href="#document-conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a>
      <li><a href="#conform-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a>
      <li>
       <a href="#conform-responsible"><span class="secno"></span> <span class="content"> Requirements for Responsible Implementation of CSS</span></a>
       <ol class="toc">
        <li><a href="#conform-partial"><span class="secno"></span> <span class="content"> Partial Implementations</span></a>
        <li><a href="#conform-future-proofing"><span class="secno"></span> <span class="content"> Implementations of Unstable and Proprietary Features</span></a>
        <li><a href="#conform-testing"><span class="secno"></span> <span class="content"> Implementations of CR-level Features</span></a>
       </ol>
     </ol>
    <li>
     <a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
     <ol class="toc">
      <li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
      <li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
     </ol>
    <li>
     <a href="#references"><span class="secno"></span> <span class="content">References</span></a>
     <ol class="toc">
      <li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
      <li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
     </ol>
    <li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
   </ol>
  </nav>
  <main>
   <h2 class="heading settled" data-level="1" id="context"><span class="secno">1. </span><span class="content"> Introduction</span><a class="self-link" href="#context"></a></h2>
   <p><em>This section is not normative.</em></p>
   <p>A <a data-link-type="dfn" href="#selector" id="ref-for-selector①">selector</a> is a boolean predicate
	that takes an element in a tree structure
	and tests whether the element matches the selector or not.</p>
   <p>These expressions may be used for many things:</p>
   <ul>
    <li> directly on an element to test whether it matches some criteria,
			such as in the <code>element.matches()</code> function defined in <a data-link-type="biblio" href="#biblio-dom">[DOM]</a> 
    <li> applied to an entire tree of elements
			to filter it into a set of elements that match the criteria,
			such as in the <code>document.querySelectorAll()</code> function defined in <a data-link-type="biblio" href="#biblio-dom">[DOM]</a> or the selector of a CSS style rule. 
    <li> used "in reverse" to generate markup that would match a given selector,
			such as in <a href="http://haml.info/">HAML</a> or <a href="https://en.wikipedia.org/wiki/Emmet_(software)">Emmet</a>. 
   </ul>
   <p>Selectors Levels 1, 2, and 3 are defined as the subsets of selector
	functionality defined in the <a href="https://www.w3.org/TR/REC-CSS1">CSS1</a>, <a href="https://www.w3.org/TR/CSS21/">CSS2.1</a>, and <a href="https://www.w3.org/TR/css3-selectors/">Selectors Level 3</a> specifications, respectively. This module defines Selectors Level 4.</p>
   <h3 class="heading settled" data-level="1.1" id="placement"><span class="secno">1.1. </span><span class="content">Module Interactions</span><a class="self-link" href="#placement"></a></h3>
   <p>This module replaces the definitions of
	and extends the set of selectors defined for CSS in <a data-link-type="biblio" href="#biblio-select">[SELECT]</a> and <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>.</p>
   <p>Pseudo-element selectors,
	which define abstract elements in a rendering tree,
	are not part of this specification:
	their generic syntax is described here,
	but, due to their close integration with the rendering model and irrelevance to other uses such as DOM queries,
	they will be defined in other modules.</p>
   <h2 class="heading settled" data-level="2" id="overview"><span class="secno">2. </span><span class="content"> Selectors Overview</span><a class="self-link" href="#overview"></a></h2>
   <p><em>This section is non-normative, as it merely summarizes the
	following sections.</em></p>
   <p>A selector represents a structure. This structure can be used as a
	condition (e.g. in a CSS rule) that determines which elements a
	selector matches in the document tree, or as a flat description of the
	HTML or XML fragment corresponding to that structure.</p>
   <p>Selectors may range from simple element names to rich contextual
	representations.</p>
   <p>The following table summarizes the Selector syntax:</p>
   <table class="data" id="selector-examples">
    <colgroup>
     <col class="pattern">
     <col class="meaning">
     <col class="section">
     <col class="level">
    <thead>
     <tr>
      <th>Pattern 
      <th>Represents 
      <th>Section 
      <th>Level 
    <tbody>
     <tr>
      <td><code>*</code> 
      <td>any element 
      <td><a href="#the-universal-selector">§ 5.2 Universal selector</a> 
      <td>2 
     <tr>
      <td><code>E</code> 
      <td>an element of type E 
      <td><a href="#type-selectors">§ 5.1 Type (tag name) selector</a> 
      <td>1 
    <tbody>
     <tr>
      <td><code>E:not(<var>s1</var>, <var>s2</var>, …)</code> 
      <td>an E element that does not match either <a data-link-type="dfn" href="#compound" id="ref-for-compound">compound selector</a> <var>s1</var> or <span id="ref-for-compound①">compound selector</span> <var>s2</var> 
      <td><a href="#negation">§ 4.3 The Negation (Matches-None) Pseudo-class: :not()</a> 
      <td>3/4 
     <tr>
      <td><code>E:is(<var>s1</var>, <var>s2</var>, …)</code> 
      <td>an E element that matches <a data-link-type="dfn" href="#compound" id="ref-for-compound②">compound selector</a> <var>s1</var> and/or <span id="ref-for-compound③">compound selector</span> <var>s2</var> 
      <td><a href="#matches">§ 4.2 The Matches-Any Pseudo-class: :is()</a> 
      <td>4 
     <tr>
      <td><code>E:where(<var>s1</var>, <var>s2</var>, …)</code> 
      <td>an E element that matches <a data-link-type="dfn" href="#compound" id="ref-for-compound④">compound selector</a> <var>s1</var> and/or <span id="ref-for-compound⑤">compound selector</span> <var>s2</var> but contributes no specificity. 
      <td><a href="#zero-matches">§ 4.4 The Specificity-adjustment Pseudo-class: :where()</a> 
      <td>4 
     <tr>
      <td><code>E:has(<var>rs1</var>, <var>rs2</var>, …)</code> 
      <td>an E element,
					if either of the <a data-link-type="dfn" href="#relative-selector" id="ref-for-relative-selector">relative selectors</a> <var>rs1</var> or <var>rs2</var>,
					when evaluated with E as the <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element">:scope elements</a>,
					match an element 
      <td><a href="#relational">§ 4.5 The Relational Pseudo-class: :has()</a> 
      <td>4 
    <tbody>
     <tr>
      <td><code>E.warning</code> 
      <td>an E element belonging to the class <code>warning</code> (the document language specifies how class is determined). 
      <td><a href="#class-html">§ 6.6 Class selectors</a> 
      <td>1 
     <tr>
      <td><code>E#myid</code> 
      <td>an E element with ID equal to <code>myid</code>. 
      <td><a href="#id-selectors">§ 6.7 ID selectors</a> 
      <td>1 
     <tr>
      <td><code>E[foo]</code> 
      <td>an E element with a <code>foo</code> attribute 
      <td><a href="#attribute-selectors">§ 6 Attribute selectors</a> 
      <td>2 
     <tr>
      <td><code>E[foo="bar"]</code> 
      <td>an E element whose <code>foo</code> attribute value is
						exactly equal to <code>bar</code> 
      <td><a href="#attribute-selectors">§ 6 Attribute selectors</a> 
      <td>2 
     <tr>
      <td><code>E[foo="bar" i]</code> 
      <td>an E element whose <code>foo</code> attribute value is
						exactly equal to any (ASCII-range) case-permutation of <code>bar</code> 
      <td><a href="#attribute-case">§ 6.3 Case-sensitivity</a> 
      <td>4 
     <tr>
      <td><code>E[foo="bar" s]</code> 
      <td>an E element whose <code>foo</code> attribute value is
						exactly and case-sensitively equal to <code>bar</code> 
      <td><a href="#attribute-case">§ 6.3 Case-sensitivity</a> 
      <td>4 
     <tr>
      <td><code>E[foo~="bar"]</code> 
      <td>an E element whose <code>foo</code> attribute value is
						a list of whitespace-separated values, one of which is
						exactly equal to <code>bar</code> 
      <td><a href="#attribute-selectors">§ 6 Attribute selectors</a> 
      <td>2 
     <tr>
      <td><code>E[foo^="bar"]</code> 
      <td>an E element whose <code>foo</code> attribute value
						begins exactly with the string <code>bar</code> 
      <td><a href="#attribute-substrings">§ 6.2 Substring matching attribute selectors</a> 
      <td>3 
     <tr>
      <td><code>E[foo$="bar"]</code> 
      <td>an E element whose <code>foo</code> attribute value
						ends exactly with the string <code>bar</code> 
      <td><a href="#attribute-substrings">§ 6.2 Substring matching attribute selectors</a> 
      <td>3 
     <tr>
      <td><code>E[foo*="bar"]</code> 
      <td>an E element whose <code>foo</code> attribute value
						contains the substring <code>bar</code> 
      <td><a href="#attribute-substrings">§ 6.2 Substring matching attribute selectors</a> 
      <td>3 
     <tr>
      <td><code>E[foo|="en"]</code> 
      <td>an E element whose <code>foo</code> attribute value is
						a hyphen-separated list of values beginning with <code>en</code> 
      <td><a href="#attribute-selectors">§ 6 Attribute selectors</a> 
      <td>2 
    <tbody>
     <tr>
      <td><code>E:dir(ltr)</code> 
      <td>an element of type E with left-to-right directionality
					(the document language specifies how directionality is determined) 
      <td><a href="#the-dir-pseudo">§ 7.1 The Directionality Pseudo-class: :dir()</a> 
      <td>4 
     <tr>
      <td><code>E:lang(zh, "*-hant")</code> 
      <td>an element of type E tagged as being either in Chinese
					(any dialect or writing system)
					or otherwise written with traditional Chinese characters 
      <td><a href="#the-lang-pseudo">§ 7.2 The Language Pseudo-class: :lang()</a> 
      <td>2/4 
    <tbody>
     <tr>
      <td><code>E:any-link</code> 
      <td>an E element being the source anchor of a hyperlink 
      <td><a href="#the-any-link-pseudo">§ 8.1 The Hyperlink Pseudo-class: :any-link</a> 
      <td>4 
     <tr>
      <td><code>E:link</code> 
      <td>an E element being the source anchor of a hyperlink
						of which the target is not yet visited 
      <td><a href="#link">§ 8.2 The Link History Pseudo-classes: :link and :visited</a> 
      <td>1 
     <tr>
      <td><code>E:visited</code> 
      <td>an E element being the source anchor of a hyperlink
						of which the target is already visited 
      <td><a href="#link">§ 8.2 The Link History Pseudo-classes: :link and :visited</a> 
      <td>1 
     <tr>
      <td><code>E:local-link</code> 
      <td>an E element being the source anchor of a hyperlink
					targetting the current URL 
      <td><a href="#the-local-link-pseudo">§ 8.3 The Local Link Pseudo-class: :local-link</a> 
      <td>4 
     <tr>
      <td><code>E:target</code> 
      <td>an E element being the target of the current URL 
      <td><a href="#the-target-pseudo">§ 8.4 The Target Pseudo-class: :target</a> 
      <td>3 
     <tr>
      <td><code>E:target-within</code> 
      <td>an E element that is the target of the current URL or contains an element that does. 
      <td><a href="#the-target-within-pseudo">§ 8.5 The Target Container Pseudo-class: :target-within</a> 
      <td>4 
     <tr>
      <td><code>E:scope</code> 
      <td>an E element being a designated reference element 
      <td><a href="#the-scope-pseudo">§ 8.6 The Reference Element Pseudo-class: :scope</a> 
      <td>4 
    <tbody>
     <tr>
      <td><code>E:current</code> 
      <td>an E element that is currently presented in a time-dimensional canvas 
      <td><a href="#time-pseudos">§ 10 Time-dimensional Pseudo-classes</a> 
      <td>4 
     <tr>
      <td><code>E:current(<var>s</var>)</code> 
      <td>an E element that is the deepest <a class="css" data-link-type="maybe" href="#current-pseudo" id="ref-for-current-pseudo">:current</a> element that
						matches selector <var>s</var> 
      <td><a href="#time-pseudos">§ 10 Time-dimensional Pseudo-classes</a> 
      <td>4 
     <tr>
      <td><code>E:past</code> 
      <td>an E element that is in the past in a time-dimensional canvas 
      <td><a href="#time-pseudos">§ 10 Time-dimensional Pseudo-classes</a> 
      <td>4 
     <tr>
      <td><code>E:future</code> 
      <td>an E element that is in the future in a time-dimensional canvas 
      <td><a href="#time-pseudos">§ 10 Time-dimensional Pseudo-classes</a> 
      <td>4 
    <tbody>
     <tr>
      <td><code>E:active</code> 
      <td>an E element that is in an activated state 
      <td><a href="#useraction-pseudos">§ 9 User Action Pseudo-classes</a> 
      <td>1 
     <tr>
      <td><code>E:hover</code> 
      <td>an E element that is under the cursor,
					or that has a descendant under the cursor 
      <td><a href="#useraction-pseudos">§ 9 User Action Pseudo-classes</a> 
      <td>2 
     <tr>
      <td><code>E:focus</code> 
      <td>an E element that has user input focus 
      <td><a href="#useraction-pseudos">§ 9 User Action Pseudo-classes</a> 
      <td>2 
     <tr>
      <td><code>E:focus-within</code> 
      <td>an E element that has user input focus or contains an element that has input focus. 
      <td><a href="#the-focus-within-pseudo">§ 9.5 The Focus Container Pseudo-class: :focus-within</a> 
      <td>4 
     <tr>
      <td><code>E:focus-visible</code> 
      <td>an E element that has user input focus,
					and the UA has determined that a focus ring or other indicator
					should be drawn for that element 
      <td><a href="#useraction-pseudos">§ 9 User Action Pseudo-classes</a> 
      <td>4 
    <tbody>
     <tr>
      <td><code>E:enabled<br>E:disabled</code> 
      <td>a user interface element E that is enabled or disabled, respectively 
      <td><a href="#enableddisabled">§ 12.1.1 The :enabled and :disabled Pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:read-write</code><br><code>E:read-only</code> 
      <td>a user interface element E that is user alterable, or not 
      <td><a href="#rw-pseudos">§ 12.1.2 The Mutability Pseudo-classes: :read-only and :read-write</a> 
      <td>3-UI/4 
     <tr>
      <td><code>E:placeholder-shown</code> 
      <td>an input control currently showing placeholder text 
      <td><a href="#placeholder">§ 12.1.3 The Placeholder-shown Pseudo-class: :placeholder-shown</a> 
      <td>3-UI/4 
     <tr>
      <td><code>E:default</code> 
      <td>a user interface element E that is the default item in a group of related choices 
      <td><a href="#the-default-pseudo">§ 12.1.4 The Default-option Pseudo-class: :default</a> 
      <td>3-UI/4 
     <tr>
      <td><code>E:checked</code> 
      <td>a user interface element E that is checked/selected
					 (for instance a radio-button or checkbox) 
      <td><a href="#checked">§ 12.2.1 The Selected-option Pseudo-class: :checked</a> 
      <td>3 
     <tr>
      <td><code>E:indeterminate</code> 
      <td>a user interface element E that is in an indeterminate state
						(neither checked nor unchecked) 
      <td><a href="#indeterminate">§ 12.2.2 The Indeterminate-value Pseudo-class: :indeterminate</a> 
      <td>4 
     <tr>
      <td><code>E:valid</code><br><code>E:invalid</code> 
      <td>a user-input element E that meets, or doesn’t, its data validity semantics 
      <td><a href="#validity-pseudos">§ 12.3.2 The Validity Pseudo-classes: :valid and :invalid</a> 
      <td>3-UI/4 
     <tr>
      <td><code>E:in-range</code><br><code>E:out-of-range</code> 
      <td>a user-input element E whose value is in-range/out-of-range 
      <td><a href="#range-pseudos">§ 12.3.3 The Range Pseudo-classes: :in-range and :out-of-range</a> 
      <td>3-UI/4 
     <tr>
      <td><code>E:required</code><br><code>E:optional</code> 
      <td>a user-input element E that requires/does not require input 
      <td><a href="#opt-pseudos">§ 12.3.4 The Optionality Pseudo-classes: :required and :optional</a> 
      <td>3-UI/4 
     <tr>
      <td><code>E:blank</code> 
      <td>a user-input element E whose value is blank (empty/missing) 
      <td><a href="#blank">§ 12.3.1 The Empty-Value Pseudo-class: :blank</a> 
      <td>4 
     <tr>
      <td><code>E:user-invalid</code> 
      <td>a user-altered user-input element E with incorrect input (invalid, out-of-range, omitted-but-required) 
      <td><a href="#user-pseudos">§ 12.3.5 The User-interaction Pseudo-class: :user-invalid</a> 
      <td>4 
    <tbody>
     <tr>
      <td><code>E:root</code> 
      <td>an E element, root of the document 
      <td><a href="#structural-pseudos">§ 13 Tree-Structural pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:empty</code> 
      <td>an E element that has no children (neither elements nor text) except perhaps white space 
      <td><a href="#structural-pseudos">§ 13 Tree-Structural pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:nth-child(<var>n</var> [of <var>S</var>]?)</code> 
      <td>an E element, the <var>n</var>-th child of its parent matching <var>S</var> 
      <td><a href="#child-index">§ 13.3 Child-indexed Pseudo-classes</a> 
      <td>3/4 
     <tr>
      <td><code>E:nth-last-child(<var>n</var> [of <var>S</var>]?)</code> 
      <td>an E element, the <var>n</var>-th child of its parent matching <var>S</var>,
						counting from the last one 
      <td><a href="#child-index">§ 13.3 Child-indexed Pseudo-classes</a> 
      <td>3/4 
     <tr>
      <td><code>E:first-child</code> 
      <td>an E element, first child of its parent 
      <td><a href="#child-index">§ 13.3 Child-indexed Pseudo-classes</a> 
      <td>2 
     <tr>
      <td><code>E:last-child</code> 
      <td>an E element, last child of its parent 
      <td><a href="#child-index">§ 13.3 Child-indexed Pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:only-child</code> 
      <td>an E element, only child of its parent 
      <td><a href="#child-index">§ 13.3 Child-indexed Pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:nth-of-type(<var>n</var>)</code> 
      <td>an E element, the <var>n</var>-th sibling of its type 
      <td><a href="#typed-child-index">§ 13.4 Typed Child-indexed Pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:nth-last-of-type(<var>n</var>)</code> 
      <td>an E element, the <var>n</var>-th sibling of its type,
						counting from the last one 
      <td><a href="#typed-child-index">§ 13.4 Typed Child-indexed Pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:first-of-type</code> 
      <td>an E element, first sibling of its type 
      <td><a href="#typed-child-index">§ 13.4 Typed Child-indexed Pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:last-of-type</code> 
      <td>an E element, last sibling of its type 
      <td><a href="#typed-child-index">§ 13.4 Typed Child-indexed Pseudo-classes</a> 
      <td>3 
     <tr>
      <td><code>E:only-of-type</code> 
      <td>an E element, only sibling of its type 
      <td><a href="#typed-child-index">§ 13.4 Typed Child-indexed Pseudo-classes</a> 
      <td>3 
    <tbody>
     <tr>
      <td><code>E F</code> 
      <td>an F element descendant of an E element 
      <td><a href="#descendant-combinators">§ 14.1 Descendant combinator ( )</a> 
      <td>1 
     <tr>
      <td><code>E > F</code> 
      <td>an F element child of an E element 
      <td><a href="#child-combinators">§ 14.2 Child combinator (>)</a> 
      <td>2 
     <tr>
      <td><code>E + F</code> 
      <td>an F element immediately preceded by an E element 
      <td><a href="#adjacent-sibling-combinators">§ 14.3 Next-sibling combinator (+)</a> 
      <td>2 
     <tr>
      <td><code>E ~ F</code> 
      <td>an F element preceded by an E element 
      <td><a href="#general-sibling-combinators">§ 14.4 Subsequent-sibling combinator (~)</a> 
      <td>3 
    <tbody>
     <tr>
      <td><code>F || E</code> 
      <td>an E element that represents a cell in a grid/table
						belonging to a column represented by an element F 
      <td><a href="#table-pseudos">§ 15 Grid-Structural Selectors</a> 
      <td>4 
     <tr>
      <td><code>E:nth-col(<var>n</var>)</code> 
      <td>an E element that represents a cell belonging to the <var>n</var>th column in a grid/table 
      <td><a href="#table-pseudos">§ 15 Grid-Structural Selectors</a> 
      <td>4 
     <tr>
      <td><code>E:nth-last-col(<var>n</var>)</code> 
      <td>an E element that represents a cell belonging to the <var>n</var>th column in a grid/table, counting from the last one 
      <td><a href="#table-pseudos">§ 15 Grid-Structural Selectors</a> 
      <td>4 
   </table>
   <p class="note" role="note"><span>Note:</span> Some Level 4 selectors (noted above as "3-UI") were introduced in <a data-link-type="biblio" href="#biblio-css3ui">[CSS3UI]</a>.</p>
   <h3 class="heading settled" data-level="2.1" id="profiles"><span class="secno">2.1. </span><span class="content"> <a data-link-type="dfn" href="#live-profile" id="ref-for-live-profile">Live</a> vs <a data-link-type="dfn" href="#snapshot-profile" id="ref-for-snapshot-profile">Snapshot</a> Selector Profiles</span><a class="self-link" href="#profiles"></a></h3>
   <p>Selectors are used in many different contexts,
	with wildly varying performance characteristics.
	Some powerful selectors are unfortunately too slow
	to realistically include in the more performance-sensitive contexts.
	To accommodate this, two profiles of the Selectors spec are defined:</p>
   <dl>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-local-lt="live" data-noexport id="live-profile">live profile</dfn> 
    <dd>
      The <a data-link-type="dfn" href="#live-profile" id="ref-for-live-profile①">live</a> profile is appropriate for use in any context,
			including browser CSS selector matching, which is live.
			It includes every selector defined in this document,
			except for: 
     <ul>
      <li>The <a class="css" data-link-type="maybe" href="#has-pseudo" id="ref-for-has-pseudo">:has()</a> pseudo-class 
     </ul>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-local-lt="snapshot" data-noexport id="snapshot-profile">snapshot profile</dfn> 
    <dd> The <a data-link-type="dfn" href="#snapshot-profile" id="ref-for-snapshot-profile①">snapshot</a> profile is appropriate for contexts which aren’t extremely performance sensitive;
			in particular, it’s appropriate for contexts which evaluate selectors against a static document tree.
			For example, the <code class="idl"><a data-link-type="idl">querySelector()</a></code> method defined in <a data-link-type="biblio" href="#biblio-dom">[DOM]</a> should use the <span id="ref-for-snapshot-profile②">snapshot</span> profile.
			It includes all of the selectors defined in this document. 
   </dl>
   <p>CSS implementations conformant to Selectors Level 4 must use the <a data-link-type="dfn" href="#live-profile" id="ref-for-live-profile②">live</a> profile for CSS selection.
	Implementations using the <span id="ref-for-live-profile③">live</span> profile must treat selectors that are not included in the profile
	as unknown and invalid.</p>
   <p class="issue" id="issue-77669937"><a class="self-link" href="#issue-77669937"></a> The categorization of things into the “live” or snapshot profiles needs implementor review.
		If some things currently not in the live profile can reasonably be done in CSS Selectors,
		we should move them. </p>
   <h2 class="heading settled" data-level="3" id="syntax"><span class="secno">3. </span><span class="content"> Selector Syntax and Structure</span><a class="self-link" href="#syntax"></a></h2>
   <h3 class="heading settled" data-level="3.1" id="structure"><span class="secno">3.1. </span><span class="content"> Structure and Terminology</span><a class="self-link" href="#structure"></a></h3>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="selector">selector</dfn> represents
	a particular pattern of element(s) in a tree structure.
	The term <a data-link-type="dfn" href="#selector" id="ref-for-selector②">selector</a> can refer to a <a data-link-type="dfn" href="#simple" id="ref-for-simple">simple selector</a>, <a data-link-type="dfn" href="#compound" id="ref-for-compound⑥">compound selector</a>, <a data-link-type="dfn" href="#complex" id="ref-for-complex">complex selector</a>, or <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list">selector list</a>.
	The <dfn class="dfn-paneled" data-dfn-for="selector" data-dfn-type="dfn" data-export data-lt="subject|subject of a selector" id="selector-subject">subject of a selector</dfn> is
	any element that selector is defined to be about;
	that is, any element <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="match" id="match">matching</dfn> that <span id="ref-for-selector③">selector</span>.</p>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="simple">simple selector</dfn> is a single condition on an element.
	A <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector">type selector</a>, <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector">universal selector</a>, <a data-link-type="dfn" href="#attribute-selector" id="ref-for-attribute-selector">attribute selector</a>, <a data-link-type="dfn" href="#class-selector" id="ref-for-class-selector">class selector</a>, <a data-link-type="dfn" href="#id-selector" id="ref-for-id-selector">ID selector</a>,
	or <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class">pseudo-class</a> is a <a data-link-type="dfn" href="#simple" id="ref-for-simple①">simple selector</a>.
	(It is represented by <a class="production css" data-link-type="type" href="#typedef-simple-selector" id="ref-for-typedef-simple-selector">&lt;simple-selector></a> in the selectors <a href="#grammar">grammar</a>.)
	A given element is said to <a data-link-type="dfn" href="#match" id="ref-for-match">match</a> a <span id="ref-for-simple②">simple selector</span> when that <span id="ref-for-simple③">simple selector</span>,
	as defined in this specification and in accordance with the <a data-link-type="dfn" href="#document-language" id="ref-for-document-language">document language</a>,
	accurately describes the element.</p>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="compound">compound selector</dfn> is a sequence of <a data-link-type="dfn" href="#simple" id="ref-for-simple④">simple selectors</a> that are not separated by a <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator">combinator</a>,
	and represents a set of simultaneous conditions on a single element.
	If it contains a <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector①">type selector</a> or <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector①">universal selector</a>,
	that selector must come first in the sequence.
	Only one type selector or universal selector is allowed in the sequence.
	(A <a data-link-type="dfn" href="#compound" id="ref-for-compound⑦">compound selector</a> is represented by <a class="production css" data-link-type="type" href="#typedef-compound-selector" id="ref-for-typedef-compound-selector">&lt;compound-selector></a> in the selectors <a href="#grammar">grammar</a>.)
	A given element is said to <a data-link-type="dfn" href="#match" id="ref-for-match①">match</a> a <span id="ref-for-compound⑧">compound selector</span> when it matches all <span id="ref-for-simple⑤">simple selectors</span> in the <span id="ref-for-compound⑨">compound selector</span>.</p>
   <p class="note" role="note"><span>Note:</span> As whitespace represents the <a data-link-type="dfn" href="#descendant-combinator" id="ref-for-descendant-combinator">descendant combinator</a>,
	no whitespace is allowed between the <a data-link-type="dfn" href="#simple" id="ref-for-simple⑥">simple selectors</a> in a <a data-link-type="dfn" href="#compound" id="ref-for-compound①⓪">compound selector</a>.</p>
   <p>A <dfn class="dfn-paneled" data-dfn-for="selector" data-dfn-type="dfn" data-export id="selector-combinator">combinator</dfn> is a condition of relationship between two elements
	represented by the <a data-link-type="dfn" href="#compound" id="ref-for-compound①①">compound selectors</a> on either side.
	Combinators in Selectors Level 4 include:
	the <a data-link-type="dfn" href="#descendant-combinator" id="ref-for-descendant-combinator①">descendant combinator</a> (white space),
	the <a data-link-type="dfn" href="#child-combinator" id="ref-for-child-combinator">child combinator</a> (U+003E, <code>></code>),
	the <a data-link-type="dfn" href="#next-sibling-combinator" id="ref-for-next-sibling-combinator">next-sibling combinator</a> (U+002B, <code>+</code>),
	and the <a data-link-type="dfn" href="#subsequent-sibling-combinator" id="ref-for-subsequent-sibling-combinator">subsequent-sibling combinator</a> (U+007E, <code>~</code>).
	Two given elements are said to <a data-link-type="dfn" href="#match" id="ref-for-match②">match</a> a <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator①">combinator</a> when the condition of relationship between these elements is true.</p>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="complex">complex selector</dfn> is
	a sequence of one or more <a data-link-type="dfn" href="#compound" id="ref-for-compound①②">compound selectors</a> separated by <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator②">combinators</a>.
	It represents a set of simultaneous conditions
	on a set of elements in the particular relationships
	described by its <span id="ref-for-selector-combinator③">combinators</span>.
	(Complex selectors are represented by <a class="production css" data-link-type="type" href="#typedef-complex-selector" id="ref-for-typedef-complex-selector">&lt;complex-selector></a> in the selectors <a href="#grammar">grammar</a>.)
	A given element is said to <a data-link-type="dfn" href="#match" id="ref-for-match③">match</a> a <a data-link-type="dfn" href="#complex" id="ref-for-complex①">complex selector</a> when there exists a list of elements,
	each matching a corresponding <span id="ref-for-compound①③">compound selector</span> in the <span id="ref-for-complex②">complex selector</span>,
	with each pair of elements consecutive in the list matching
	the <span id="ref-for-selector-combinator④">combinator</span> between their corresponding <span id="ref-for-compound①④">compound selectors</span>,
	and with the last element being the given element.</p>
   <p class="note" role="note"><span>Note:</span> Thus, a selector consisting of a single <a data-link-type="dfn" href="#compound" id="ref-for-compound①⑤">compound selector</a> matches any element satisfying the requirements
	of its constituent <a data-link-type="dfn" href="#simple" id="ref-for-simple⑦">simple selectors</a>.
	Prepending another <span id="ref-for-compound①⑥">compound selector</span> and a <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator⑤">combinator</a> to a sequence imposes additional matching constraints,
	such that the <a data-link-type="dfn" href="#selector-subject" id="ref-for-selector-subject">subjects</a> of a <a data-link-type="dfn" href="#complex" id="ref-for-complex③">complex selector</a> are always
	a subset of the elements represented by its last <span id="ref-for-compound①⑦">compound selector</span>.</p>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="list of simple selectors|list of compound selectors|list of complex selectors" id="list-of-simple-selectors">list of simple/compound/complex selectors</dfn> is a comma-separated list of <a data-link-type="dfn" href="#simple" id="ref-for-simple⑧">simple</a>, <a data-link-type="dfn" href="#compound" id="ref-for-compound①⑧">compound</a>,
	or <a data-link-type="dfn" href="#complex" id="ref-for-complex④">complex selectors</a>.
	This is also called just a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="selector list|list of selectors" id="selector-list">selector list</dfn> when the type is either unimportant or specified in the surrounding prose;
	if the type is important and unspecified,
	it defaults to meaning a <a data-link-type="dfn" href="#list-of-simple-selectors" id="ref-for-list-of-simple-selectors">list of complex selectors</a>.
	(See <a href="#grouping">§ 4.1 Selector Lists</a> for additional information on <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list①">selector lists</a> and the various &lt;*-selector-list> productions in the <a href="#grammar">grammar</a> for their formal syntax.)
	A given element is said to <a data-link-type="dfn" href="#match" id="ref-for-match④">match</a> a <span id="ref-for-selector-list②">selector list</span> when it matches any (at least one) of the <a data-link-type="dfn" href="#selector" id="ref-for-selector④">selectors</a> in that <span id="ref-for-selector-list③">selector list</span>.</p>
   <p class="issue" id="issue-5830d0c1"><a class="self-link" href="#issue-5830d0c1"></a> Pseudo-elements aren’t handled here, and should be.</p>
   <h3 class="heading settled" data-level="3.2" id="data-model"><span class="secno">3.2. </span><span class="content"> Data Model</span><a class="self-link" href="#data-model"></a></h3>
   <p>Selectors are evaluated against an element tree such as the DOM. <a data-link-type="biblio" href="#biblio-dom">[DOM]</a> Within this specification,
	this may be referred to as the "document tree" or "source document".</p>
   <p>Each element may have any of the following five aspects,
	which can be selected against,
	all of which are matched as strings:</p>
   <ul>
    <li>The element’s type (also known as its tag name). 
    <li>The element’s namespace. 
    <li>An ID. 
    <li>Classes (named groups) to which it belongs. 
    <li>Attributes, which are name-value pairs. 
   </ul>
   <p>While individual elements may lack any of the above features,
	some elements are <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="featureless">featureless</dfn>.
	A <a data-link-type="dfn" href="#featureless" id="ref-for-featureless">featureless</a> element does not match any selector at all,
	except those it is explicitly defined to match.
	If a given selector <em>is</em> allowed to match a <span id="ref-for-featureless①">featureless</span> element,
	it must do so while ignoring the default namespace. <a data-link-type="biblio" href="#biblio-css3namespace">[CSS3NAMESPACE]</a></p>
   <div class="example" id="example-76c361e3"><a class="self-link" href="#example-76c361e3"></a> For example, the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#element-shadow-host" id="ref-for-element-shadow-host">shadow host</a> in a <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-tree" id="ref-for-concept-shadow-tree">shadow tree</a> is <a data-link-type="dfn" href="#featureless" id="ref-for-featureless②">featureless</a>,
		and can’t be matched by <em>any</em> <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class①">pseudo-class</a> except for <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-scoping-1/#selectordef-host" id="ref-for-selectordef-host">:host</a> and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-scoping-1/#selectordef-host-context" id="ref-for-selectordef-host-context">:host-context()</a>.) </div>
   <p>Many of the selectors depend on the semantics of the <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="document-language">document language</dfn> (i.e. the language and semantics of the document tree)
	and/or the semantics of the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="host-language">host language</dfn> (i.e. the language that is using selectors syntax).
	For example, the <a class="css" data-link-type="maybe" href="#lang-pseudo" id="ref-for-lang-pseudo">:lang()</a> selector depends on the <a data-link-type="dfn" href="#document-language" id="ref-for-document-language①">document language</a> (e.g. HTML)
	to define how an element is associated with a language.
	As a slightly different example, the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line" id="ref-for-selectordef-first-line">::first-line</a> pseudo-element
	depends on the <a data-link-type="dfn" href="#host-language" id="ref-for-host-language">host language</a> (e.g. CSS)
	to define what a <span class="css" id="ref-for-selectordef-first-line①">::first-line</span> pseudo-element represents
	and what it can do.</p>
   <h3 class="heading settled" data-level="3.3" id="scoping"><span class="secno">3.3. </span><span class="content"> Scoped Selectors</span><a class="self-link" href="#scoping"></a></h3>
   <p>Some host applications may choose to <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-local-lt="scope" data-lt="scoped selector" id="scoped-selector">scope</dfn> selectors
	to a particular subtree or fragment of the document.
	The root of the scoping subtree is called the <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="scoping-root">scoping root</dfn>,
	and may be either a true element (the <dfn data-dfn-type="dfn" data-export id="scoping-element">scoping element<a class="self-link" href="#scoping-element"></a></dfn>)
	or a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="virtual scoping root" id="virtual-scoping-root">virtual</dfn> one (such as a <a class="idl-code" data-link-type="interface" href="https://dom.spec.whatwg.org/#documentfragment" id="ref-for-documentfragment">DocumentFragment</a>).</p>
   <p>When a selector is <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector">scoped</a>,
	it matches an element only if the element is a descendant of the <a data-link-type="dfn" href="#scoping-root" id="ref-for-scoping-root">scoping root</a>.
	(The rest of the selector can match unrestricted;
	it’s only the final matched elements that must be within the scope.)</p>
   <div class="example" id="example-d2142ebe">
    <a class="self-link" href="#example-d2142ebe"></a> For example,
		the <code>element.querySelector()</code> function defined in <a data-link-type="biblio" href="#biblio-dom">[DOM]</a> allows the author to evaluate a <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector①">scoped</a> selector
		relative to the <code>element</code> it’s called on. 
    <p>A call like <code class="highlight">widget<c- p>.</c->querySelector<c- p>(</c-><c- u>"a"</c-><c- p>)</c-></code> will thus only find <code><a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a">a</a></code> elements inside of the <code>widget</code> element,
		ignoring any other <code><a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a①">a</a></code>s that might be scattered throughout the document.</p>
   </div>
   <p class="note" role="note"><span>Note:</span> If the context does not explicitly define any <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element①">:scope elements</a> for the selector,
	the <a data-link-type="dfn" href="#scoping-root" id="ref-for-scoping-root①">scoping root</a> is the <span id="ref-for-scope-element②">:scope element</span>.</p>
   <h3 class="heading settled" data-level="3.4" id="relative"><span class="secno">3.4. </span><span class="content"> Relative Selectors</span><a class="self-link" href="#relative"></a></h3>
   <p>Certain contexts may accept <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="relative selector | relative | scope-relative" id="relative-selector">relative selectors</dfn>,
	which are a shorthand for selectors that represent elements relative to a <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element③">:scope element</a> (i.e. an element that matches <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo">:scope</a>).
	In a <a data-link-type="dfn" href="#relative-selector" id="ref-for-relative-selector①">relative selector</a>,
	“:scope ” (the <span class="css" id="ref-for-scope-pseudo①">:scope</span> pseudo-class followed by a space)
	is implied at the beginning of each <a data-link-type="dfn" href="#complex" id="ref-for-complex⑤">complex selector</a> that does not already contain the <span class="css" id="ref-for-scope-pseudo②">:scope</span> pseudo-class.
	This allows the selector to begin syntactically with a <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator⑥">combinator</a>.
	However, it must be <a href="#absolutize" id="ref-for-absolutize">absolutized</a> before matching.</p>
   <p>Relative selectors, once absolutized,
	can additionally be <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector②">scoped</a>.</p>
   <p>Relative selectors are represented by <a class="production css" data-link-type="type" href="#typedef-relative-selector" id="ref-for-typedef-relative-selector">&lt;relative-selector></a> in the selectors <a href="#grammar">grammar</a>.</p>
   <h4 class="heading settled" data-level="3.4.1" id="absolutizing"><span class="secno">3.4.1. </span><span class="content"> Absolutizing a Relative Selector</span><a class="self-link" href="#absolutizing"></a></h4>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="absolutize">absolutize a relative selector</dfn>:</p>
   <p>If there are no <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element④">:scope elements</a> and the selector is <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector③">scoped</a> to a <a data-link-type="dfn" href="#virtual-scoping-root" id="ref-for-virtual-scoping-root">virtual scoping root</a>:</p>
   <p class="issue" id="issue-28dbdaca"><a class="self-link" href="#issue-28dbdaca"></a> <a href="https://github.com/w3c/csswg-drafts/issues/2199">This needs a sane definition.</a></p>
   <p>Otherwise:</p>
   <ol>
    <li> If the selector starts with a <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator⑦">combinator</a> other than the white space form of the <a data-link-type="dfn" href="#descendant-combinator" id="ref-for-descendant-combinator②">descendant combinator</a>,
			prepend <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo③">:scope</a> as the initial <a data-link-type="dfn" href="#compound" id="ref-for-compound①⑨">compound selector</a>. 
    <li> Otherwise, if the selector does not contain any instance of the <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo④">:scope</a> pseudo-class
			(either at the top-level or as an argument to a functional pseudo-class),
			prepend <span class="css" id="ref-for-scope-pseudo⑤">:scope</span> followed by the white space form of the <a data-link-type="dfn" href="#descendant-combinator" id="ref-for-descendant-combinator③">descendant combinator</a>. 
    <li> Otherwise, the selector is already absolute. 
   </ol>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="absolutize-list">absolutize a relative selector list</dfn>,
	absolutize each relative selector in the list.</p>
   <h3 class="heading settled" data-level="3.5" id="pseudo-classes"><span class="secno">3.5. </span><span class="content"> Pseudo-classes</span><a class="self-link" href="#pseudo-classes"></a></h3>
   <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="pseudo-class" id="pseudo-class">Pseudo-classes</dfn> are <a data-link-type="dfn" href="#simple" id="ref-for-simple⑨">simple selectors</a> that permit selection based on
	information that lies outside of the document tree
	or that can be awkward or impossible to express using the other simple selectors.
	They can also be dynamic,
	in the sense that an element can acquire or lose a pseudo-class
	while a user interacts with the document,
	without the document itself changing. <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class②">Pseudo-classes</a> do not appear in or modify the document source or document tree.</p>
   <p>The syntax of a <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class③">pseudo-class</a> consists of a ":" (U+003A COLON)
	followed by the name of the <span id="ref-for-pseudo-class④">pseudo-class</span> as a CSS <a data-link-type="dfn" href="https://drafts.csswg.org/css-syntax-3/#identifier" id="ref-for-identifier">identifier</a>,
	and, in the case of a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="functional-pseudo-class">functional pseudo-class</dfn>,
	a pair of parentheses containing its arguments.</p>
   <p class="example" id="example-86ae2021"><a class="self-link" href="#example-86ae2021"></a> For example, <a class="css" data-link-type="maybe" href="#valid-pseudo" id="ref-for-valid-pseudo">:valid</a> is a regular pseudo-class,
		and <a class="css" data-link-type="maybe" href="#lang-pseudo" id="ref-for-lang-pseudo①">:lang()</a> is a <a data-link-type="dfn" href="#functional-pseudo-class" id="ref-for-functional-pseudo-class">functional pseudo-class</a>. </p>
   <p>Like all CSS keywords, <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class⑤">pseudo-class</a> names are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive">ASCII case-insensitive</a>.
	No <a data-link-type="dfn" href="#whitespace" id="ref-for-whitespace">white space</a> is allowed between the colon and the name of the <span id="ref-for-pseudo-class⑥">pseudo-class</span>,
	nor, as usual for CSS syntax,
	between a <a data-link-type="dfn" href="#functional-pseudo-class" id="ref-for-functional-pseudo-class①">functional pseudo-class</a>’s name and its opening parenthesis
	(which thus form a CSS <a data-link-type="dfn">function token</a>).
	Also as usual, <span id="ref-for-whitespace①">white space</span> is allowed around the arguments inside the parentheses
	of a functional pseudo-class
	unless otherwise specified.</p>
   <p>Like other <a data-link-type="dfn" href="#simple" id="ref-for-simple①⓪">simple selectors</a>, <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class⑦">pseudo-classes</a> are allowed in all <a data-link-type="dfn" href="#compound" id="ref-for-compound②⓪">compound selectors</a> contained in a selector,
	and must follow the <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector②">type selector</a> or <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector②">universal selector</a>, if present.</p>
   <p class="note" role="note"><span>Note:</span> Some <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class⑧">pseudo-classes</a> are mutually exclusive
	(such that a <a data-link-type="dfn" href="#compound" id="ref-for-compound②①">compound selector</a> containing them, while valid, will never match anything),
	while others can apply simultaneously to the same element.</p>
   <h3 class="heading settled" data-level="3.6" id="pseudo-elements"><span class="secno">3.6. </span><span class="content">Pseudo-elements</span><a class="self-link" href="#pseudo-elements"></a></h3>
   <p>Similar to how certain <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class⑨">pseudo-classes</a> represent additional state information
	not directly present in the document tree,
	a <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="pseudo-element">pseudo-element</dfn> represents an <em>element</em> not directly present in the document tree.
	They are used to create abstractions about the document tree
	beyond those provided by the document tree.
	For example,
	pseudo-elements can be used to select portions of the document
	that do not correspond to a document-language element
	(including such ranges as don’t align to element boundaries or fit within its tree structure);
	that represent content not in the document tree or in an alternate projection of the document tree;
	or that rely on information provided by styling, layout, user interaction, and other processes that are not reflected in the document tree.</p>
   <div class="example" id="example-6916597f">
    <a class="self-link" href="#example-6916597f"></a> For instance, document languages do not offer mechanisms to access
		the first letter or first line of an element’s content,
		but there exist <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element">pseudo-elements</a> (<a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter" id="ref-for-selectordef-first-letter">::first-letter</a> and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line" id="ref-for-selectordef-first-line②">::first-line</a>)
		that allow those things to be styled.
		Notice especially that in the case of <span class="css" id="ref-for-selectordef-first-line③">::first-line</span>,
		which portion of content is represented by the pseudo-element
		depends on layout information
		that cannot be inferred from the document tree. 
    <p><a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element①">Pseudo-elements</a> can also represent content that doesn’t exist in the source document at all,
		such as the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-before" id="ref-for-selectordef-before">::before</a> and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-after" id="ref-for-selectordef-after">::after</a> pseudo-elements
		which allow additional content to be inserted before or after the contents of any element.</p>
   </div>
   <p>Like <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class①⓪">pseudo-classes</a> <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②">pseudo-elements</a> do not appear in or modify the document source or document tree.
	Accordingly, they also do not affect the interpretation of <a data-link-type="dfn" href="#structural-pseudo-classes" id="ref-for-structural-pseudo-classes">structural pseudo-classes</a> or other selectors pertaining to their <a data-link-type="dfn" href="#originating-element" id="ref-for-originating-element">originating element</a> or its tree.</p>
   <p>The host language defines which pseudo-elements exist, their type, and their abilities.
	Pseudo-elements that exist in CSS
	are defined in <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a> (Level 2), <a data-link-type="biblio" href="#biblio-select">[SELECT]</a> (Level 3), and <a data-link-type="biblio" href="#biblio-css-pseudo-4">[CSS-PSEUDO-4]</a> (Level 4).</p>
   <h4 class="heading settled" data-level="3.6.1" id="pseudo-element-syntax"><span class="secno">3.6.1. </span><span class="content"> Syntax</span><a class="self-link" href="#pseudo-element-syntax"></a></h4>
   <p>The syntax of a <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element③">pseudo-element</a> is "::" (two U+003A COLON characters)
	followed by the name of the <span id="ref-for-pseudo-element④">pseudo-element</span> as an <a data-link-type="dfn" href="https://drafts.csswg.org/css-syntax-3/#identifier" id="ref-for-identifier①">identifier</a>. <span id="ref-for-pseudo-element⑤">Pseudo-element</span> names are <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive①">ASCII case-insensitive</a>.
	No <a data-link-type="dfn" href="#whitespace" id="ref-for-whitespace②">white space</a> is allowed between the two colons, or between the colons and the name.</p>
   <p>Because <a href="https://www.w3.org/TR/CSS1">CSS Level 1</a> and <a href="https://www.w3.org/TR/CSS2">CSS Level 2</a> conflated pseudo-elements and pseudo-classes by sharing a single-colon syntax for both,
	user agents must also accept the previous one-colon notation
	for the Level 1 &amp; 2 pseudo-elements
	(<a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-before" id="ref-for-selectordef-before①">::before</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-after" id="ref-for-selectordef-after①">::after</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line" id="ref-for-selectordef-first-line④">::first-line</a>, and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter" id="ref-for-selectordef-first-letter①">::first-letter</a>).
	This compatibility notation is not allowed any other <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element⑥">pseudo-elements</a>.
	However, as this syntax is deprecated,
	authors should use the Level 3+ double-colon syntax for these <span id="ref-for-pseudo-element⑦">pseudo-elements</span>.</p>
   <p><a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element⑧">Pseudo-elements</a> are <a data-link-type="dfn" href="#featureless" id="ref-for-featureless③">featureless</a>,
	and so can’t be matched by any other selector.</p>
   <h4 class="heading settled" data-level="3.6.2" id="pseudo-element-attachment"><span class="secno">3.6.2. </span><span class="content"> Binding to the Document Tree</span><a class="self-link" href="#pseudo-element-attachment"></a></h4>
   <p><a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element⑨">Pseudo-elements</a> do not exist independently in the tree:
	they are always bound to another element on the page,
	called their <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="originating-element">originating element</dfn>.
	Syntactically, a <span id="ref-for-pseudo-element①⓪">pseudo-element</span> immediately follows
	the <a data-link-type="dfn" href="#compound" id="ref-for-compound②②">compound selector</a> representing its <a data-link-type="dfn" href="#originating-element" id="ref-for-originating-element①">originating element</a>.
	If this <span id="ref-for-compound②③">compound selector</span> is omitted,
	it is assumed to be the <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector③">universal selector</a> <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-3/#x" id="ref-for-x">*</a>.</p>
   <div class="example" id="example-e6d9ca44">
    <a class="self-link" href="#example-e6d9ca44"></a> For example, in the selector <span class="css">div a::before</span>,
		the <span class="css">a</span> elements matched by the selector are the <a data-link-type="dfn" href="#originating-element" id="ref-for-originating-element②">originating elements</a> for the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-before" id="ref-for-selectordef-before②">::before</a> pseudo-elements attached to them. 
    <p>The selector <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line" id="ref-for-selectordef-first-line⑤">::first-line</a> is equivalent to <span class="css">*::first-line</span>,
		which selects the <span class="css" id="ref-for-selectordef-first-line⑥">::first-line</span> pseudo-element on <em>every</em> element in the document.</p>
   </div>
   <p>When a <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element①①">pseudo-element</a> is encountered in a selector,
	the part of the selector before the <span id="ref-for-pseudo-element①②">pseudo-element</span> selects the <a data-link-type="dfn" href="#originating-element" id="ref-for-originating-element③">originating element</a> for the <span id="ref-for-pseudo-element①③">pseudo-element</span>;
	the part of the selector after it, if any, applies to the <span id="ref-for-pseudo-element①④">pseudo-element</span> itself.
	(See below.)</p>
   <h4 class="heading settled" data-level="3.6.3" id="pseudo-element-states"><span class="secno">3.6.3. </span><span class="content"> Pseudo-classing Pseudo-elements</span><a class="self-link" href="#pseudo-element-states"></a></h4>
   <p>A <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element①⑤">pseudo-element</a> may be immediately followed
	by any combination of the <a href="#useraction-pseudos">user action pseudo-classes</a>,
	in which case the <span id="ref-for-pseudo-element①⑥">pseudo-element</span> is represented only when it is in the corresponding state.
	Whether these pseudo-classes can match on the <span id="ref-for-pseudo-element①⑦">pseudo-element</span> depends on the <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class①①">pseudo-class</a> and <span id="ref-for-pseudo-element①⑧">pseudo-element</span>’s definitions:
	unless otherwise-specified, none of these <span id="ref-for-pseudo-class①②">pseudo-classes</span> will match on the <span id="ref-for-pseudo-element①⑨">pseudo-element</span>.</p>
   <p class="issue" id="issue-9f34fdb4"><a class="self-link" href="#issue-9f34fdb4"></a> Clarify that <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo">:not()</a> and <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo">:is()</a> can be used when containing above-mentioned pseudos.</p>
   <div class="example" id="example-01167664">
    <a class="self-link" href="#example-01167664"></a> For example, since the <a class="css" data-link-type="maybe" href="#hover-pseudo" id="ref-for-hover-pseudo">:hover</a> pseudo-class specifies
		that it can apply to any pseudo-element, <span class="css">::first-line:hover</span> will match when the first line is hovered.
		However, since neither <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo">:focus</a> nor <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line" id="ref-for-selectordef-first-line⑦">::first-line</a> define that <span class="css" id="ref-for-focus-pseudo①">:focus</span> can apply to <span class="css" id="ref-for-selectordef-first-line⑧">::first-line</span>,
		the selector <span class="css">::first-line:focus</span> will never match anything. 
    <p class="issue" id="issue-27c4806a"><a class="self-link" href="#issue-27c4806a"></a> Does <span class="css">::first-line:not(:focus)</span> match anything?</p>
    <p>Notice that <span class="css">::first-line:hover</span> is very different from <span class="css">:hover::first-line</span>,
		which matches the first line of any originating element that is hovered!
		For example, <span class="css">:hover::first-line</span> also matches the first line of a paragraph
		when the second line of the paragraph is hovered,
		whereas <span class="css">::first-line:hover</span> only matches if the first line itself is hovered.</p>
   </div>
   <p class="note" role="note"><span>Note:</span> Note that, unless otherwise specified in a future specification,
	pseudo-classes other than the <a href="#useraction-pseudos">user action pseudo-classes</a> are not valid when compounded to a pseudo-element;
	so, for example, <span class="css">::before:first-child</span> is an invalid selector.</p>
   <h4 class="heading settled" data-level="3.6.4" id="pseudo-element-structure"><span class="secno">3.6.4. </span><span class="content"> Internal Structure</span><a class="self-link" href="#pseudo-element-structure"></a></h4>
   <p>Some <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②⓪">pseudo-elements</a> are defined to have internal structure.
	These <span id="ref-for-pseudo-element②①">pseudo-elements</span> may be followed by child/descendant combinators
	to express those relationships.
	Selectors containing <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator⑧">combinators</a> after the pseudo-element
	are otherwise invalid.</p>
   <div class="example" id="example-ed91d05b"><a class="self-link" href="#example-ed91d05b"></a> For example, <span class="css">::first-letter + span</span> and <span class="css">::first-letter em</span> are invalid selectors.
		However, since <a class="css" data-link-type="maybe" href="https://www.w3.org/TR/css-scoping-1/#selectordef-shadow" id="ref-for-selectordef-shadow">::shadow</a> is defined to have internal structure, <span class="css">::shadow > p</span> is a valid selector. </div>
   <p class="note" role="note"><span>Note:</span> A future specification may expand the capabilities of existing pseudo-elements,
	so some of these currently-invalid selectors (e.g. <span class="css">::first-line :any-link</span>)
	may become valid in the future.</p>
   <p>The children of such <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②②">pseudo-elements</a> can simultaneously be children of other elements, too.
	However, at least in CSS, their rendering must be defined so as to maintain the tree-ness of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#box tree" id="ref-for-box tree">box tree</a>.</p>
   <div class="example" id="example-5dddce2e">
    <a class="self-link" href="#example-5dddce2e"></a> For example,
		the <a class="css" data-link-type="maybe" href="https://www.w3.org/TR/css-scoping-1/#selectordef-content" id="ref-for-selectordef-content">::content</a> pseudo-element treats elements distributed to it as its children.
		This means that, given the following fragment: 
<pre>&lt;div>
  &lt;span>foo&lt;/span>
  &lt;"shadow root">
    &lt;content>&lt;/content>
  &lt;/"shadow root">
&lt;/div>
</pre>
    <p>the selectors <span class="css">div > span</span> and <span class="css">div::shadow ::content > span</span> select the same element via different paths.</p>
    <p>However, when rendered,
		the <code>&lt;span></code> element generates boxes as if it were the child of the <code>&lt;content></code> element,
		rather than the <code>&lt;div></code> element,
		so the tree structure of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#box tree" id="ref-for-box tree①">box tree</a> is maintained.</p>
   </div>
   <h3 class="heading settled" data-level="3.7" id="case-sensitive"><span class="secno">3.7. </span><span class="content"> Characters and case sensitivity</span><a class="self-link" href="#case-sensitive"></a></h3>
   <p>All Selectors syntax is case-insensitive within the ASCII range
	(i.e. [a-z]  and [A-Z] are equivalent),
	except for the parts
	that are not under the control of Selectors:
	specifically,
	the case-sensitivity of
	document language element names,
	attribute names,
	and attribute values
	depends on the document language.</p>
   <div class="example" id="example-5ac03fca"><a class="self-link" href="#example-5ac03fca"></a> For example, <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selectors">in HTML, element and attribute names are ASCII case-insensitive</a>,
		but in XML, they are case-sensitive. </div>
   <p>Case sensitivity of namespace prefixes is defined in <a data-link-type="biblio" href="#biblio-css3namespace">[CSS3NAMESPACE]</a>.
	Case sensitivity of <a data-link-type="dfn" href="#language-range" id="ref-for-language-range">language ranges</a> is defined in the <a class="css" data-link-type="maybe" href="#lang-pseudo" id="ref-for-lang-pseudo②">:lang()</a> section.</p>
   <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="whitespace">White space</dfn> in Selectors consists of the
	code points SPACE (U+0020), TAB (U+0009), LINE FEED (U+000A),
	CARRIAGE RETURN (U+000D), and FORM FEED (U+000C).
	Other space-like code points, such as EM SPACE (U+2003) and
	IDEOGRAPHIC SPACE (U+3000), are never considered syntactic white space.</p>
   <p>Code points in Selectors can be escaped with a backslash
	according to the same <a href="https://www.w3.org/TR/CSS21/syndata.html#characters">escaping rules</a> as CSS. <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a> Note that escaping a code point “cancels out”
	any special meaning it may have in Selectors.
	For example, the selector <span class="css">#foo>a</span> contains a combinator,
	but <span class="css">#foo\>a</span> instead selects an element with the id <code>foo>a</code>.</p>
   <h3 class="heading settled" data-level="3.8" id="namespaces"><span class="secno">3.8. </span><span class="content"> Declaring Namespace Prefixes</span><a class="self-link" href="#namespaces"></a></h3>
   <p>Certain selectors support namespace prefixes.
	The mechanism by which namespace prefixes are <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="nsdecl">declared</dfn> should be specified by the language that uses Selectors.
	If the language does not specify a namespace prefix declaration mechanism,
	then no prefixes are declared.
	In CSS, namespace prefixes are declared with the <span class="css">@namespace</span> rule. <a data-link-type="biblio" href="#biblio-css3namespace">[CSS3NAMESPACE]</a></p>
   <h3 class="heading settled" data-level="3.9" id="invalid"><span class="secno">3.9. </span><span class="content"> Invalid Selectors and Error Handling</span><a class="self-link" href="#invalid"></a></h3>
   <p>User agents must observe the rules for handling <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-local-lt="invalid" data-lt="invalid selector" id="invalid-selector">invalid selectors</dfn>:</p>
   <ul>
    <li>a parsing error in a selector,
			e.g. an unrecognized token or a token which is not allowed at the current parsing point
			(see overall <a href="#grammar">§ 17 Grammar</a> and per-selector syntax definitions),
			causes that selector to be invalid. 
    <li>a simple selector containing an <a href="#namespaces">undeclared namespace prefix</a> is invalid 
    <li>a selector containing an invalid simple selector, an invalid combinator
			or an invalid token is invalid. 
    <li>a selector list containing an invalid selector is invalid. 
    <li>an empty selector, i.e. one that contains no <a data-link-type="dfn" href="#compound" id="ref-for-compound②④">compound selector</a>, is invalid. 
   </ul>
   <p class="issue" id="issue-897fe327"><a class="self-link" href="#issue-897fe327"></a> The CSSWG indends to modify these rules such that an invalid selector
	in the selector list argument of a pseudo-class like `:is()`
	is simply ignored rather than invalidating the whole selector list.
	See <a href="https://github.com/w3c/csswg-drafts/issues/3264">Issue 3264</a>.</p>
   <p class="note" role="note"><span>Note:</span> Consistent with CSS’s forwards-compatible parsing principle,
	UAs <em>must</em> treat as <a data-link-type="dfn" href="#invalid-selector" id="ref-for-invalid-selector">invalid</a> any pseudo-classes, pseudo-elements, combinators, or other syntactic constructs
	for which they have no usable level of support.
	See <a href="#conform-partial">Partial Implementations</a>.</p>
   <p>An <a data-link-type="dfn" href="#invalid-selector" id="ref-for-invalid-selector①">invalid selector</a> represents, and therefore matches, nothing.</p>
   <h2 class="heading settled" data-level="4" id="logical-combination"><span class="secno">4. </span><span class="content"> Logical Combinations</span><a class="self-link" href="#logical-combination"></a></h2>
   <h3 class="heading settled" data-level="4.1" id="grouping"><span class="secno">4.1. </span><span class="content"> Selector Lists</span><a class="self-link" href="#grouping"></a></h3>
   <p>A comma-separated list of selectors represents the union of all
	elements selected by each of the individual selectors in the <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list④">selector list</a>.
	(A comma is U+002C.) For example, in CSS when several selectors share
	the same declarations, they may be grouped into a comma-separated
	list. White space may appear before and/or after the comma.</p>
   <div class="example" id="example-1930da7e">
    <a class="self-link" href="#example-1930da7e"></a> CSS example:
		In this example, we condense three rules with identical
		declarations into one. Thus, 
<pre>h1 { font-family: sans-serif }
h2 { font-family: sans-serif }
h3 { font-family: sans-serif }
</pre>
    <p>is equivalent to:</p>
<pre>h1, h2, h3 { font-family: sans-serif }
</pre>
   </div>
   <p><strong>Warning</strong>: the equivalence is true in this example
	because all the selectors are valid selectors. If just one of these
	selectors were invalid, the entire <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list⑤">selector list</a> would be
	invalid. This would invalidate the rule for all three heading
	elements, whereas in the former case only one of the three individual
	heading rules would be invalidated.</p>
   <div class="example" id="example-fd0daa05">
    <a class="self-link" href="#example-fd0daa05"></a> Invalid CSS example: 
<pre>h1 { font-family: sans-serif }
h2..foo { font-family: sans-serif }
h3 { font-family: sans-serif }
</pre>
    <p>is not equivalent to:</p>
<pre>h1, h2..foo, h3 { font-family: sans-serif } </pre>
    <p>because the above selector (<span class="css">h1, h2..foo, h3</span>)
		is entirely invalid and the entire style rule is dropped. (When
		the selectors are not grouped, only the rule for <span class="css">h2..foo</span> is dropped.)</p>
   </div>
   <h3 class="heading settled" data-level="4.2" id="matches"><span class="secno">4.2. </span><span class="content"> The Matches-Any Pseudo-class: <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①">:is()</a></span><a class="self-link" href="#matches"></a></h3>
   <p>The matches-any pseudo-class, <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="matches-pseudo">:is()</dfn>,
	is a functional pseudo-class taking a <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list⑥">selector list</a> as its argument.
	It represents an element that is represented by its argument.</p>
   <p class="note" role="note"><span>Note:</span> The specificity of the <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo②">:is()</a> pseudo-class
	is replaced by the specificity of its most specific argument.
	Thus, a selector written with <span class="css" id="ref-for-matches-pseudo③">:is()</span> does not necessarily have equivalent specificity
	to the equivalent selector written without <span class="css" id="ref-for-matches-pseudo④">:is()</span> For example, if we have <span class="css">:is(ul, ol, .list) > [hidden]</span> and <span class="css">ul > [hidden], ol > [hidden], .list > [hidden]</span> a <span class="css">[hidden]</span> child of an <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-ol-element" id="ref-for-the-ol-element">ol</a></code> matches the first selector
	with a specificity of (0,2,0)
	whereas it matches the second selector
	with a specificity of (0,1,1).
	See <a href="#specificity-rules">§ 16 Calculating a selector’s specificity</a>.</p>
   <p>Pseudo-elements cannot be represented by the matches-any pseudo-class;
	they are not valid within <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo⑤">:is()</a>.</p>
   <p>Default namespace declarations do not affect the <a data-link-type="dfn" href="#compound" id="ref-for-compound②⑤">compound selector</a> representing the <a data-link-type="dfn" href="#selector-subject" id="ref-for-selector-subject①">subject</a> of any selector
	within a <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo⑥">:is()</a> pseudo-class,
	unless that compound selector contains
	an explicit <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector④">universal selector</a> or <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector③">type selector</a>.</p>
   <div class="example" id="example-2cab03ed">
    <a class="self-link" href="#example-2cab03ed"></a> For example, the following selector matches any element that is being
		hovered or focused, regardless of its namespace. In particular, it
		is not limited to only matching elements in the default namespace
		that are being hovered or focused. 
<pre>*|*:is(:hover, :focus) </pre>
    <p>The following selector, however, represents only hovered or focused
		elements that are in the default namespace, because it uses an explicit
		universal selector within the <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo⑦">:is()</a> notation:</p>
<pre>*|*:is(*:hover, *:focus) </pre>
   </div>
   <p>As previous drafts of this specification
	used the name <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="selectordef-matches">:matches()</dfn> for this pseudo-class,
	UAs may additionally implement this obsolete name
	as an alias for <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo⑧">:is()</a> if needed for backwards-compatibility.</p>
   <h3 class="heading settled" data-level="4.3" id="negation"><span class="secno">4.3. </span><span class="content"> The Negation (Matches-None) Pseudo-class: <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo①">:not()</a></span><a class="self-link" href="#negation"></a></h3>
   <p>The negation pseudo-class, <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="negation-pseudo">:not()</dfn>,
	is a functional pseudo-class taking a <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list⑦">selector list</a> as an argument.
	It represents an element that is not represented by its argument.</p>
   <p class="note" role="note"><span>Note:</span> In Selectors Level 3,
	only a single <a data-link-type="dfn" href="#simple" id="ref-for-simple①①">simple selector</a> was allowed as the argument to <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo②">:not()</a>.</p>
   <p class="note" role="note"><span>Note:</span> The specificity of the <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo③">:not()</a> pseudo-class
	is replaced by the specificity of the most specific selector in its argument;
	thus it has the exact behavior of <span class="css">:not(:is(argument))</span>.
	See <a href="#specificity-rules">§ 16 Calculating a selector’s specificity</a>.</p>
   <p>Pseudo-elements cannot be represented by the negation pseudo-class;
	they are not valid within <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo④">:not()</a>.</p>
   <div class="example" id="example-2a176618">
    <a class="self-link" href="#example-2a176618"></a> For example, the following selector matches all <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element" id="ref-for-the-button-element">button</a> elements in an HTML document
		that are not disabled. 
<pre>button:not([DISABLED]) </pre>
    <p>The following selector represents all but FOO elements.</p>
<pre>*:not(FOO)</pre>
    <p>The following compound selector represents all HTML elements
		except links.</p>
<pre>html|*:not(:link):not(:visited)</pre>
   </div>
   <p>As with <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo⑨">:is()</a>,
	default namespace declarations do not affect the <a data-link-type="dfn" href="#compound" id="ref-for-compound②⑥">compound selector</a> representing the <a data-link-type="dfn" href="#selector-subject" id="ref-for-selector-subject②">subject</a> of any selector
	within a <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo⑤">:not()</a> pseudo-class,
	unless that compound selector contains
	an explicit <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector⑤">universal selector</a> or <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector④">type selector</a>.
	(See <span class="css" id="ref-for-matches-pseudo①⓪">:is()</span> for examples.)</p>
   <p class="note" role="note"><span>Note:</span> The <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo⑥">:not()</a> pseudo-class allows useless selectors to be written.
	For instance <span class="css">:not(*|*)</span>, which represents no element at all,
	or <span class="css">div:not(span)</span>, which is equivalent to <span class="css">div</span> but with a higher specificity.</p>
   <h3 class="heading settled" data-level="4.4" id="zero-matches"><span class="secno">4.4. </span><span class="content"> The Specificity-adjustment Pseudo-class: <a class="css" data-link-type="maybe" href="#where-pseudo" id="ref-for-where-pseudo">:where()</a></span><a class="self-link" href="#zero-matches"></a></h3>
   <p>The Specificity-adjustment pseudo-class, <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="where-pseudo">:where()</dfn>,
	is a functional pseudo-class
	with the same syntax and functionality as <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①①">:is()</a>.
	Unlike <span class="css" id="ref-for-matches-pseudo①②">:is()</span>, neither the <span class="css">:where</span> pseudo-class, nor any of its arguments
	contribute to the specificity of the selector—<wbr>its specificity is always zero.</p>
   <p>This is useful for introducing filters in a selector
	while keeping the associated style declarations easy to override.</p>
   <div class="example" id="example-7ca50acf">
    <a class="self-link" href="#example-7ca50acf"></a> Below is a common example where the specificity heuristic fails
		to match author expectations: 
<pre>a:not(:hover) {
  text-decoration: none;
}

nav a {
  /* Has no effect */
  text-decoration: underline;
}
</pre>
    <p>However, by using <a class="css" data-link-type="maybe" href="#where-pseudo" id="ref-for-where-pseudo①">:where()</a> the author can explicitly declare their intent:</p>
<pre>a:where(:not(:hover)) {
  text-decoration: none;
}

nav a {
  /* Works now! */
  text-decoration: underline;
}
</pre>
   </div>
   <p class="note" role="note"><span>Note:</span> Future levels of Selectors may introduce an additional argument
	to explicitly set the specificity of that instance of the pseudo-class.</p>
   <h3 class="heading settled" data-level="4.5" id="relational"><span class="secno">4.5. </span><span class="content"> The Relational Pseudo-class: <a class="css" data-link-type="maybe" href="#has-pseudo" id="ref-for-has-pseudo①">:has()</a></span><a class="self-link" href="#relational"></a></h3>
   <p>The relational pseudo-class, <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="has-pseudo">:has()</dfn>,
	is a functional pseudo-class taking a <a data-link-type="dfn" href="#relative-selector" id="ref-for-relative-selector②">relative selector</a> <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list⑧">list</a> as an argument.
	It represents an element if any of the <span id="ref-for-relative-selector③">relative selectors</span>,
	when <a href="#absolutize" id="ref-for-absolutize①">absolutized</a> and evaluated with the element as the <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element⑤">:scope elements</a>,
	would match at least one element.</p>
   <div class="example" id="example-8c66af53">
    <a class="self-link" href="#example-8c66af53"></a> For example, the following selector matches only <code>&lt;a></code> elements that contain an <code>&lt;img></code> child: 
<pre>a:has(> img)</pre>
    <p>The following selector matches a <code>&lt;dt></code> element
		immediately followed by another <code>&lt;dt></code> element:</p>
<pre>dt:has(+ dt)</pre>
    <p>The following selector matches <code>&lt;section></code> elements
		that don’t contain any heading elements:</p>
<pre>section:not(:has(h1, h2, h3, h4, h5, h6))</pre>
    <p>Note that ordering matters in the above selector.
		Swapping the nesting of the two pseudo-classes, like:</p>
<pre>section:has(:not(h1, h2, h3, h4, h5, h6))</pre>
    <p>...would result matching any <code>&lt;section></code> element
		which contains anything that’s not a heading element.</p>
   </div>
   <h2 class="heading settled" data-level="5" id="elemental-selectors"><span class="secno">5. </span><span class="content"> Elemental selectors</span><a class="self-link" href="#elemental-selectors"></a></h2>
   <h3 class="heading settled" data-level="5.1" id="type-selectors"><span class="secno">5.1. </span><span class="content"> Type (tag name) selector</span><a class="self-link" href="#type-selectors"></a></h3>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="type-selector">type selector</dfn> is the name of a document language element type,
	and represents an instance of that element type in the document tree.</p>
   <div class="example" id="example-087f4a77"><a class="self-link" href="#example-087f4a77"></a> For example, the selector <span class="css">h1</span> represents an <a data-link-type="element">h1</a> element in the document. </div>
   <p>A <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector⑤">type selector</a> is written as a <a data-link-type="dfn" href="https://drafts.csswg.org/css-namespaces-3/#css-qualified-name" id="ref-for-css-qualified-name">CSS qualified name</a>:
	an <a data-link-type="dfn" href="https://drafts.csswg.org/css-syntax-3/#identifier" id="ref-for-identifier②">identifier</a> with an optional namespace prefix. <a data-link-type="biblio" href="#biblio-css3namespace">[CSS3NAMESPACE]</a> (See <a href="#type-nmsp">§ 5.3 Namespaces in Elemental Selectors</a>.)</p>
   <h3 class="heading settled" data-level="5.2" id="the-universal-selector"><span class="secno">5.2. </span><span class="content"> Universal selector </span><a class="self-link" href="#the-universal-selector"></a></h3>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="universal-selector">universal selector</dfn> is a special <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector⑥">type selector</a>,
	that represents an element of any element type.</p>
   <p>It is written as a <a data-link-type="dfn" href="https://drafts.csswg.org/css-namespaces-3/#css-qualified-name" id="ref-for-css-qualified-name①">CSS qualified name</a> with an asterisk (<code>*</code> U+002A) as the local name.
	Like a <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector⑦">type selector</a>,
	the <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector⑥">universal selector</a> can be qualified by a namespace,
	restricting it to only elements belonging to that namespace,
	and is affected by a default namespace as defined in <a href="#type-nmsp">§ 5.3 Namespaces in Elemental Selectors</a>.</p>
   <p>Unless an element is <a data-link-type="dfn" href="#featureless" id="ref-for-featureless④">featureless</a>,
	the presence of a <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector⑦">universal selector</a> has no effect on whether the element matches the selector.
	(<span id="ref-for-featureless⑤">Featureless</span> elements do not match any selector,
		including the <span id="ref-for-universal-selector⑧">universal selector</span>.)</p>
   <div class="example" id="example-0f5d51ca">
    <a class="self-link" href="#example-0f5d51ca"></a> 
    <ul>
     <li> <span class="css">*[hreflang|=en]</span> and <span class="css">[hreflang|=en]</span> are equivalent, 
     <li><span class="css">*.warning</span> and <span class="css">.warning</span> are equivalent, 
     <li><span class="css">*#myid</span> and <span class="css">#myid</span> are equivalent. 
    </ul>
   </div>
   <p>The <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector⑨">universal selector</a> follows the same syntax rules as other <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector⑧">type selectors</a>:
	only one can appear per <a data-link-type="dfn" href="#compound" id="ref-for-compound②⑦">compound selector</a>,
	and it must be the first <a data-link-type="dfn" href="#simple" id="ref-for-simple①②">simple selector</a> in the <span id="ref-for-compound②⑧">compound selector</span>.</p>
   <p class="note" role="note"><span>Note:</span> In some cases, adding a <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector①⓪">universal selector</a> can make a selector easier to read,
	even though it has no effect on the matching behavior.
	For example, <span class="css">div :first-child</span> and <span class="css">div:first-child</span> are somewhat difficult to tell apart at a quick glance,
	but writing the former as <span class="css">div *:first-child</span> makes the difference obvious.</p>
   <h3 class="heading settled" data-level="5.3" id="type-nmsp"><span class="secno">5.3. </span><span class="content"> Namespaces in Elemental Selectors</span><a class="self-link" href="#type-nmsp"></a></h3>
   <p><a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector⑨">Type selectors</a> and <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector①①">universal selectors</a> allow an optional namespace component:
	a namespace prefix that has been previously <a href="#nsdecl" id="ref-for-nsdecl">declared</a> may be prepended to the element name separated by the namespace separator “vertical bar” (<code>|</code> U+007C).
	(See, e.g., <a data-link-type="biblio" href="#biblio-xml-names">[XML-NAMES]</a> for the use of namespaces in XML.)
	It has the following meaning in each form:</p>
   <dl>
    <dt><code>ns|E</code> 
    <dd> elements with name E in namespace ns 
    <dt><code>*|E</code> 
    <dd> elements with name E in any namespace,
			including those without a namespace 
    <dt><code>|E</code> 
    <dd> elements with name E without a namespace 
    <dt><code>E</code> 
    <dd> if no default namespace has been <a href="#nsdecl" id="ref-for-nsdecl①">declared</a> for selectors,
			this is equivalent to *|E.
			Otherwise it is equivalent to ns|E
			where ns is the default namespace. 
   </dl>
   <div class="example" id="example-53e1ab95">
    <a class="self-link" href="#example-53e1ab95"></a> CSS examples: 
<pre>@namespace foo url(http://www.example.com);
foo|h1 { color: blue }  /* first rule */
foo|* { color: yellow } /* second rule */
|h1 { color: red }      /* ...*/
*|h1 { color: green }
h1 { color: green }
</pre>
    <p>The first rule (not counting the <span class="css">@namespace</span> at-rule)
		will match only <a data-link-type="element">h1</a> elements in the
		"http://www.example.com" namespace.</p>
    <p>The second rule will match all elements in the
		"http://www.example.com" namespace.</p>
    <p>The third rule will match only <a data-link-type="element">h1</a> elements with
		no namespace.</p>
    <p>The fourth rule will match <a data-link-type="element">h1</a> elements in any
		namespace (including those without any namespace).</p>
    <p>The last rule is equivalent to the fourth rule because no default
		namespace has been defined.</p>
   </div>
   <p>If a <a data-link-type="dfn" href="https://drafts.csswg.org/css-namespaces-3/#default-namespace" id="ref-for-default-namespace">default namespace</a> is declared, <a data-link-type="dfn" href="#compound" id="ref-for-compound②⑨">compound selectors</a> without <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector①⓪">type selectors</a> in them
	still only match elements in that default namespace.</p>
   <div class="example" id="example-03281ceb">
    <a class="self-link" href="#example-03281ceb"></a> For example,
		in the following style sheet: 
<pre>@namespace url("http://example.com/foo");

.special { ... }
</pre>
    <p>The <span class="css">.special</span> selector only matches elements in the "http://example.com/foo" namespace,
		even though no reference to the type name (which is paired with the namespace in the DOM) appeared.</p>
   </div>
   <p>A <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector①①">type selector</a> or <a data-link-type="dfn" href="#universal-selector" id="ref-for-universal-selector①②">universal selector</a> containing a namespace prefix
	that has not been previously <a href="#nsdecl" id="ref-for-nsdecl②">declared</a> is an <a data-link-type="dfn" href="#invalid-selector" id="ref-for-invalid-selector②">invalid selector</a>.</p>
   <h2 class="heading settled" data-level="6" id="attribute-selectors"><span class="secno">6. </span><span class="content"> Attribute selectors</span><a class="self-link" href="#attribute-selectors"></a></h2>
   <p>Selectors allow the representation of an element’s attributes. When
	a selector is used as an expression to match against an element,
	an <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="attribute-selector">attribute selector</dfn> must be considered to match an element if that
	element has an attribute that matches the attribute represented by the
	attribute selector.</p>
   <p class="issue" id="issue-745ef775"><a class="self-link" href="#issue-745ef775"></a>Add comma-separated syntax for <a href="http://lists.w3.org/Archives/Public/www-style/2011Mar/0215.html">multiple-value matching</a>?
	e.g. [rel ~= next, prev, up, first, last] </p>
   <h3 class="heading settled" data-level="6.1" id="attribute-representation"><span class="secno">6.1. </span><span class="content"> Attribute presence and value selectors</span><a class="self-link" href="#attribute-representation"></a></h3>
   <p>CSS2 introduced four attribute selectors:</p>
   <dl>
    <dt><span class="css">[att]</span> 
    <dd> Represents an element with the <code>att</code> attribute,
			whatever the value of the attribute. 
    <dt><span class="css">[att=val]</span> 
    <dd> Represents an element with the <code>att</code> attribute
			whose value is exactly "val". 
    <dt><span class="css">[att~=val]</span> 
    <dd> Represents an element with the <code>att</code> attribute
			whose value is a <a href="#whitespace" id="ref-for-whitespace③">whitespace</a>-separated list of words,
			one of which is exactly "val".
			If "val" contains whitespace,
			it will never represent anything
			(since the words are <em>separated</em> by spaces).
			Also if "val" is the empty string,
			it will never represent anything. 
    <dt><span class="css">[att|=val]</span> 
    <dd> Represents an element with the <code>att</code> attribute,
			its value either being exactly "val"
			or beginning with "val" immediately followed by "-" (U+002D).
			This is primarily intended to allow language subcode matches
			(e.g., the <code>hreflang</code> attribute on the <a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a②">a</a> element in HTML)
			as described in BCP 47 (<a data-link-type="biblio" href="#biblio-bcp47">[BCP47]</a>) or its successor.
			For <code>lang</code> (or <code>xml:lang</code>) language subcode matching,
			please see the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-3/#sel-lang" id="ref-for-sel-lang">:lang</a> pseudo-class. 
   </dl>
   <p>Attribute values must be <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token">&lt;ident-token></a>s or <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-string-token" id="ref-for-typedef-string-token">&lt;string-token></a>s. <a data-link-type="biblio" href="#biblio-css3syn">[CSS3SYN]</a></p>
   <div class="example" id="example-52ee808b">
    <a class="self-link" href="#example-52ee808b"></a> Examples: 
    <p>The following attribute selector represents an <a data-link-type="element">h1</a> element
		that carries the <code>title</code> attribute,
		whatever its value:</p>
<pre>h1[title]</pre>
    <p>In the following example, the selector represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-span-element" id="ref-for-the-span-element">span</a> element whose <code>class</code> attribute has
		exactly the value "example":</p>
<pre>span[class="example"]</pre>
    <p>Multiple attribute selectors can be used to represent several
		attributes of an element, or several conditions on the same
		attribute. Here, the selector represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-span-element" id="ref-for-the-span-element①">span</a> element
		whose <code>hello</code> attribute has exactly the value "Cleveland"
		and whose <code>goodbye</code> attribute has exactly the value
		"Columbus":</p>
<pre>span[hello="Cleveland"][goodbye="Columbus"]</pre>
    <p>The following CSS rules illustrate the differences between
		"=" and "~=".  The first selector would match, for example, an <a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a③">a</a> element with the value "copyright copyleft
		copyeditor" on a <code>rel</code> attribute. The second selector
		would only match an <span id="ref-for-elementdef-a④">a</span> element with an <code>href</code> attribute having the exact value "http://www.w3.org/".</p>
<pre>a[rel~="copyright"] { ... }
a[href="http://www.w3.org/"] { ... }
</pre>
    <p>The following selector represents an <a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a⑤">a</a> element
		whose <code>hreflang</code> attribute is exactly "fr".</p>
<pre>a[hreflang=fr] </pre>
    <p>The following selector represents an <a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a⑥">a</a> element for
		which the value of the <code>hreflang</code> attribute begins with
		"en", including "en", "en-US", and "en-scouse":</p>
<pre>a[hreflang|="en"] </pre>
    <p>The following selectors represent a <a data-link-type="element">DIALOGUE</a> element
		whenever it has one of two different values for an attribute <code>character</code>:</p>
<pre>DIALOGUE[character=romeo]
DIALOGUE[character=juliet]
</pre>
   </div>
   <h3 class="heading settled" data-level="6.2" id="attribute-substrings"><span class="secno">6.2. </span><span class="content"> Substring matching attribute selectors</span><a class="self-link" href="#attribute-substrings"></a></h3>
   <p>Three additional attribute selectors are provided for matching
	substrings in the value of an attribute:</p>
   <dl>
    <dt><span class="css">[att^=val]</span> 
    <dd> Represents an element with the <code>att</code> attribute
			whose value begins with the prefix "val".
			If "val" is the empty string
			then the selector does not represent anything. 
    <dt><span class="css">[att$=val]</span> 
    <dd> Represents an element with the <code>att</code> attribute
			whose value ends with the suffix "val".
			If "val" is the empty string
			then the selector does not represent anything. 
    <dt><span class="css">[att*=val]</span> 
    <dd> Represents an element with the <code>att</code> attribute
			whose value contains at least one instance of the substring "val".
			If "val" is the empty string
			then the selector does not represent anything. 
   </dl>
   <p>Attribute values must be <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token①">&lt;ident-token></a>s or <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-string-token" id="ref-for-typedef-string-token①">&lt;string-token></a>s.</p>
   <div class="example" id="example-d887e2c3">
    <a class="self-link" href="#example-d887e2c3"></a> Examples:
		The following selector represents an HTML <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element" id="ref-for-the-object-element">object</a> element,
		referencing an image: 
<pre>object[type^="image/"] </pre>
    <p>The following selector represents an HTML <a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a⑦">a</a> element
		with an <code>href</code> attribute whose value ends with ".html".</p>
<pre>a[href$=".html"] </pre>
    <p>The following selector represents an HTML paragraph
		with a <code>title</code> attribute whose value contains the substring "hello"</p>
<pre>p[title*="hello"] </pre>
   </div>
   <h3 class="heading settled" data-level="6.3" id="attribute-case"><span class="secno">6.3. </span><span class="content"> Case-sensitivity</span><a class="self-link" href="#attribute-case"></a></h3>
   <p>By default case-sensitivity of attribute names and values in selectors
	depends on the document language.</p>
   <p>To match attribute values case-insensitively
	regardless of document language rules,
	the attribute selector may include the identifier <code>i</code> before the closing bracket (<code>]</code>).
	When this flag is present,
	UAs must match the attribute’s value
	case-insensitively within the ASCII range.</p>
   <p>Alternately, the attribute selector may include the identifier <code>s</code> before the closing bracket (<code>]</code>);
	in this case the UA must match the value case-sensitively (if possible)
	regardless of document language rules.</p>
   <p>Like the rest of Selectors syntax,
	the <code>i</code> and <code>s</code> identifiers are <a href="#case-sensitive">case-insensitive</a> within the ASCII range.</p>
   <div class="example" id="example-348bad1b">
    <a class="self-link" href="#example-348bad1b"></a> The following rule will style the <code>frame</code> attribute when it
		has a value of <code>hsides</code>, whether that value is represented
		as <code>hsides</code>, <code>HSIDES</code>, <code>hSides</code>, etc.
		even in an XML environment where attribute values are case-sensitive. 
<pre>[frame=hsides i] { border-style: solid none; } </pre>
   </div>
   <div class="example" id="example-f596236d">
    <a class="self-link" href="#example-f596236d"></a> The following rule will style lists with <code>type="a"</code> attributes differently than <code>type="A"</code> even though HTML defines the <code>type</code> attribute
		to be case-insensitive. 
<pre>[type="a" s] { list-style: lower-alpha; }
[type="A" s] { list-style: upper-alpha; }
</pre>
   </div>
   <p class="note" role="note"><span>Note:</span> Some document models normalize case-insensitive attribute values
	at parse time such that case-sensitive matching is impossible.
	Case-sensitive matching via <code>s</code> flags is only possible
	in systems that preserve the original case.</p>
   <h3 class="heading settled" data-level="6.4" id="attrnmsp"><span class="secno">6.4. </span><span class="content"> Attribute selectors and namespaces</span><a class="self-link" href="#attrnmsp"></a></h3>
   <p>The attribute name in an attribute selector is given as a <a href="https://www.w3.org/TR/css3-namespace/#css-qnames">CSS qualified
	name</a>: a namespace prefix that has been previously <a href="#nsdecl" id="ref-for-nsdecl③">declared</a> may be prepended to the attribute name separated by the namespace
	separator "vertical bar" (<code>|</code>). In keeping with
	the Namespaces in the XML recommendation, default namespaces do not
	apply to attributes, therefore attribute selectors without a namespace
	component apply only to attributes that have no namespace (equivalent
	to <span class="css">|attr</span>). An asterisk may be used for
	the namespace prefix indicating that the selector is to match all
	attribute names without regard to the attribute’s namespace.</p>
   <p>An attribute selector with an attribute name containing a namespace
	prefix that has not been previously <a href="#nsdecl" id="ref-for-nsdecl④">declared</a> is
	an <a href="#conformance">invalid</a> selector.</p>
   <div class="example" id="example-a7ca2cb1">
    <a class="self-link" href="#example-a7ca2cb1"></a> CSS examples: 
<pre>@namespace foo "http://www.example.com";
[foo|att=val] { color: blue }
[*|att] { color: yellow }
[|att] { color: green }
[att] { color: green }
</pre>
    <p>The first rule will match only elements with the attribute <code>att</code> in the "http://www.example.com" namespace with the
		value "val".</p>
    <p>The second rule will match only elements with the attribute <code>att</code> regardless of the namespace of the attribute
		(including no namespace).</p>
    <p>The last two rules are equivalent and will match only elements
		with the attribute <code>att</code> where the attribute is not
		in a namespace.</p>
   </div>
   <h3 class="heading settled" data-level="6.5" id="def-values"><span class="secno">6.5. </span><span class="content"> Default attribute values in DTDs</span><a class="self-link" href="#def-values"></a></h3>
   <p>Attribute selectors represent attribute values in the document tree.
	How that document tree is constructed is outside the scope of Selectors.
	In some document formats default attribute values can be defined in a DTD or
	elsewhere, but these can only be selected by attribute selectors if they
	appear in the document tree. Selectors should be designed so that they
	work whether or not the default values are included in the document tree.</p>
   <p>For example, a XML UA may, but is <em>not</em> required to,
	read an “external subset” of the DTD, but <em>is</em> required to
	look for default attribute values in the document’s “internal subset”.
	(See, e.g., <a data-link-type="biblio" href="#biblio-xml10">[XML10]</a> for definitions of these subsets.)
	Depending on the UA, a default attribute value defined in the external subset of the DTD
	might or might not appear in the document tree.</p>
   <p>A UA that recognizes an XML namespace may, but is not required to use its
	knowledge of that namespace to treat default attribute values as if
	they were present in the document. (For example, an XHTML UA is not
	required to use its built-in knowledge of the XHTML DTD. See, e.g., <a data-link-type="biblio" href="#biblio-xml-names">[XML-NAMES]</a> for details on namespaces in XML
	1.0.)</p>
   <p class="note" role="note"><span>Note:</span> Typically, implementations
	choose to ignore external subsets. This corresponds to the behavior
	of non-validating processors as defined by the XML specification.</p>
   <div class="example" id="example-2ffa5c63">
    <a class="self-link" href="#example-2ffa5c63"></a> Example: 
    <p>Consider an element <code>EXAMPLE</code> with an attribute <code>radix</code> that has a default value of <code>"decimal"</code>. The DTD fragment might be</p>
<pre class="dtd-example">&lt;!ATTLIST EXAMPLE radix (decimal,octal) "decimal"> </pre>
    <p>If the style sheet contains the rules</p>
<pre>EXAMPLE[radix=decimal] { /*... default property settings ...*/ }
EXAMPLE[radix=octal]   { /*... other settings...*/ }
</pre>
    <p>the first rule might not match elements whose <code>radix</code> attribute is
		set by default, i.e. not set explicitly. To catch all cases, the
		attribute selector for the default value must be dropped:</p>
<pre>EXAMPLE                { /*... default property settings ...*/ }
EXAMPLE[radix=octal]   { /*... other settings...*/ }
</pre>
    <p>Here, because the selector ''EXAMPLE[radix=octal]'' is
		more specific than the type selector alone, the style declarations in
		the second rule will override those in the first for elements that
		have a <code>radix</code> attribute value of <code>"octal"</code>. Care has to be taken that
		all property declarations that are to apply only to the default case
		are overridden in the non-default cases' style rules.</p>
   </div>
   <h3 class="heading settled" data-level="6.6" id="class-html"><span class="secno">6.6. </span><span class="content"> Class selectors</span><a class="self-link" href="#class-html"></a></h3>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="class-selector">class selector</dfn> is given as a full stop (. U+002E) immediately
	followed by an identifier. It represents an element belonging to the
	class identified by the identifier, as defined by the document language.
	For example, in <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>, <a data-link-type="biblio" href="#biblio-svg11">[SVG11]</a>, and <a data-link-type="biblio" href="#biblio-mathml">[MATHML]</a> membership in a
	class is given by the <code>class</code> attribute: in these languages
	it is equivalent to the <code>~=</code> notation applied to the
	local <code>class</code> attribute
	(i.e. <code>[class~=<var>identifier</var>]</code>).</p>
   <div class="example" id="example-f9c08b5b">
    <a class="self-link" href="#example-f9c08b5b"></a> CSS examples: 
    <p>We can assign style information to all elements with <code>class~="pastoral"</code> as follows:</p>
<pre>*.pastoral { color: green }  /* all elements with class~=pastoral */ </pre>
    <p>or just</p>
<pre>.pastoral { color: green }  /* all elements with class~=pastoral */ </pre>
    <p>The following assigns style only to H1 elements with <code>class~="pastoral"</code>:</p>
<pre>H1.pastoral { color: green }  /* H1 elements with class~=pastoral */ </pre>
    <p>Given these rules, the first <code>H1</code> instance below would not have
		green text, while the second would:</p>
<pre>&lt;H1>Not green&lt;/H1>
&lt;H1 class="pastoral">Very green&lt;/H1>
</pre>
    <p>The following rule matches any <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element">P</a> element whose <code>class</code> attribute has been assigned a list of <a href="#whitespace" id="ref-for-whitespace④">whitespace</a>-separated values that includes both <code>pastoral</code> and <code>marine</code>:</p>
<pre>p.pastoral.marine { color: green } </pre>
    <p>This rule matches when <code>class="pastoral blue aqua
		marine"</code> but does not match for <code>class="pastoral
		blue"</code>.</p>
   </div>
   <p class="note" role="note"><span>Note:</span> Because CSS gives considerable
	power to the "class" attribute, authors could conceivably design their
	own "document language" based on elements with almost no associated
	presentation (such as <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-div-element" id="ref-for-the-div-element">div</a> and <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-span-element" id="ref-for-the-span-element②">span</a> in HTML)
	and assigning style
	information through the "class" attribute.  Authors should avoid this
	practice since the structural elements of a document language often
	have recognized and accepted meanings and author-defined classes may
	not.</p>
   <p class="note" role="note"><span>Note:</span> If an element has multiple
	class attributes, their values must be concatenated with spaces
	between the values before searching for the class. As of this time the
	working group is not aware of any manner in which this situation can
	be reached, however, so this behavior is explicitly non-normative in
	this specification.</p>
   <p>When matching against a document which is in <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-document-quirks" id="ref-for-concept-document-quirks">quirks mode</a>,
	class names must be matched <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive②">ASCII case-insensitively</a>;
	class selectors are otherwise case-sensitive.</p>
   <h3 class="heading settled" data-level="6.7" id="id-selectors"><span class="secno">6.7. </span><span class="content"> ID selectors</span><a class="self-link" href="#id-selectors"></a></h3>
   <p>Document languages may contain attributes that are declared to be of type ID.
	What makes attributes of type ID special
	is that no two such attributes can have the same value in a conformant document,
	regardless of the type of the elements that carry them;
	whatever the document language,
	an ID typed attribute can be used to uniquely identify its element.
	In HTML all ID attributes are named <code>id</code>;
	XML applications may name ID attributes differently,
	but the same restriction applies.
	Which attribute on an element is considered the “ID attribute“ is defined by the document language.</p>
   <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="id-selector">ID selector</dfn> consists of a “number sign” (U+0023, <code>#</code>)
	immediately followed by the ID value,
	which must be a CSS <a href="https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier">identifier</a>.
	An ID selector represents an element instance that has an identifier that matches the identifier in the ID selector.
	(It is possible in non-conforming documents for multiple elements to match a single ID selector.)</p>
   <div class="example" id="example-3e8dc597">
    <a class="self-link" href="#example-3e8dc597"></a> Examples:
		The following ID selector represents an <a data-link-type="element">h1</a> element
		whose ID-typed attribute has the value "chapter1": 
<pre>h1#chapter1 </pre>
    <p>The following ID selector represents any element whose ID-typed
		attribute has the value "chapter1":</p>
<pre>#chapter1 </pre>
    <p>The following selector represents any element whose ID-typed
		attribute has the value "z98y".</p>
<pre>*#z98y </pre>
   </div>
   <p class="note" role="note"><span>Note:</span> In XML 1.0 <a data-link-type="biblio" href="#biblio-xml10">[XML10]</a>, the information about which attribute
	contains an element’s IDs is contained in a DTD or a schema. When
	parsing XML, UAs do not always read the DTD, and thus may not know
	what the ID of an element is (though a UA may have namespace-specific
	knowledge that allows it to determine which attribute is the ID
	attribute for that namespace). If a style sheet author knows or
	suspects that a UA may not know what the ID of an element is, he
	should use normal attribute selectors instead:
	''[name=p371]<span class="css"> instead of </span>#p371''.</p>
   <p>If an element has multiple ID attributes, all of them must be
	treated as IDs for that element for the purposes of the ID
	selector. Such a situation could be reached using mixtures of xml:id,
	DOM3 Core, XML DTDs, and namespace-specific knowledge.</p>
   <p>When matching against a document which is in <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-document-quirks" id="ref-for-concept-document-quirks①">quirks mode</a>,
	IDs must be matched <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive③">ASCII case-insensitively</a>;
	ID selectors are otherwise case-sensitive.</p>
   <h2 class="heading settled" data-level="7" id="linguistic-pseudos"><span class="secno">7. </span><span class="content"> Linguistic Pseudo-classes</span><a class="self-link" href="#linguistic-pseudos"></a></h2>
   <h3 class="heading settled" data-level="7.1" id="the-dir-pseudo"><span class="secno">7.1. </span><span class="content"> The Directionality Pseudo-class: <a class="css" data-link-type="maybe" href="#dir-pseudo" id="ref-for-dir-pseudo">:dir()</a></span><a class="self-link" href="#the-dir-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="dir-pseudo">:dir()</dfn> pseudo-class allows the author to write
	selectors that represent an element based on its directionality
	as determined by the <a data-link-type="dfn" href="#document-language" id="ref-for-document-language②">document language</a>.
	For example, <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> defines <a href="https://html.spec.whatwg.org/multipage/dom.html#the-directionality">how to determine the directionality of an element</a>,
	based on a combination of the <code>dir</code> attribute, the surrounding text, and other factors.
	As another example, the <code>its:dir</code> and <code>dirRule</code> element
	of the Internationalization Tag Set <a data-link-type="biblio" href="#biblio-its20">[ITS20]</a> are able to define the directionality of an element in <a data-link-type="biblio" href="#biblio-xml10">[XML10]</a>.</p>
   <p>The <a class="css" data-link-type="maybe" href="#dir-pseudo" id="ref-for-dir-pseudo①">:dir()</a> pseudo-class does not select based on stylistic
	states—for example, the CSS <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction" id="ref-for-propdef-direction">direction</a> property does not affect
	whether it matches.</p>
   <p>The pseudo-class <span class="css">:dir(ltr)</span> represents an element that
	has a directionality of left-to-right (<code>ltr</code>). The
	pseudo-class <span class="css">:dir(rtl)</span> represents an element that has
	a directionality of right-to-left (<code>rtl</code>). The argument to <a class="css" data-link-type="maybe" href="#dir-pseudo" id="ref-for-dir-pseudo②">:dir()</a> must be a single identifier, otherwise the selector
	is invalid. White space is optionally allowed between the identifier
	and the parentheses. Values other than <code>ltr</code> and <code>rtl</code> are not invalid, but do not match anything. (If a
	future markup spec defines other directionalities, then Selectors may
	be extended to allow corresponding values.)</p>
   <p>The difference between <span class="css">:dir(C)</span> and ''[dir=C]''
	is that ''[dir=C]'' only performs a comparison against a given
	attribute on the element, while the <span class="css">:dir(C)</span> pseudo-class
	uses the UAs knowledge of the document’s semantics to perform the
	comparison. For example, in HTML, the directionality of an element
	inherits so that a child without a <code>dir</code> attribute will have
	the same directionality as its closest ancestor with a valid <code>dir</code> attribute. As another example, in HTML,
	an element that matches ''[dir=auto]'' will match either <span class="css">:dir(ltr)</span> or <span class="css">:dir(rtl)</span> depending on the resolved
	directionality of the elements as determined by its contents. <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a></p>
   <h3 class="heading settled" data-level="7.2" id="the-lang-pseudo"><span class="secno">7.2. </span><span class="content"> The Language Pseudo-class: <a class="css" data-link-type="maybe" href="#lang-pseudo" id="ref-for-lang-pseudo③">:lang()</a></span><a class="self-link" href="#the-lang-pseudo"></a></h3>
   <p>If the document language specifies how
	the (human) <a data-link-type="dfn" href="https://drafts.csswg.org/css-text-3/#content-language" id="ref-for-content-language">content language</a> of an element is determined,
	it is possible to write selectors that
	represent an element based on its <span id="ref-for-content-language①">content language</span>.
	The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="lang-pseudo">:lang()</dfn> pseudo-class represents an element that
	is in one of the languages listed in its argument. It accepts
	a comma-separated list of one or more <a data-link-type="dfn" href="#language-range" id="ref-for-language-range①">language ranges</a> as its
	argument. Each <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="language-range">language range</dfn> in <a class="css" data-link-type="maybe" href="#lang-pseudo" id="ref-for-lang-pseudo④">:lang()</a> must be a valid CSS <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-ident" id="ref-for-typedef-ident">&lt;ident></a> or <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#string-value" id="ref-for-string-value">&lt;string></a>.
	(Language ranges containing asterisks, for example,
		must be either correctly escaped or quoted as strings,
		e.g. <span class="css">:lang(\*-Latn)</span> or <span class="css">:lang("*-Latn")</span>)</p>
   <p class="note" role="note"><span>Note:</span> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-text-3/#content-language" id="ref-for-content-language②">content language</a> of an element is defined by the document language.
	For example, in HTML <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>, the <span id="ref-for-content-language③">content language</span> is determined by a
	combination of the <code>lang</code> attribute, information from <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/semantics.html#meta" id="ref-for-meta">meta</a> elements, and possibly also the protocol (e.g.
	from HTTP headers). XML languages can use the <code>xml:lang</code> attribute to indicate language information for an element. <a data-link-type="biblio" href="#biblio-xml10">[XML10]</a></p>
   <p>The element’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-text-3/#content-language" id="ref-for-content-language④">content language</a> matches a <a data-link-type="dfn" href="#language-range" id="ref-for-language-range②">language range</a> if
	its <span id="ref-for-content-language⑤">content language</span>, as represented in BCP 47 syntax,
	matches the given <span id="ref-for-language-range③">language range</span> in an <var>extended filtering</var> operation per <a data-link-type="biblio" href="#biblio-rfc4647">[RFC4647]</a> <cite>Matching of Language Tags</cite> (section 3.3.2).
	The matching is performed case-insensitively within the ASCII range.
	The <span id="ref-for-language-range④">language range</span> does not need to be a valid language code to
	perform this comparison.</p>
   <p class="note" role="note"><span>Note:</span> It is recommended that
	documents and protocols indicate language using codes from BCP 47 <a data-link-type="biblio" href="#biblio-bcp47">[BCP47]</a> or its successor, and by means of <code>xml:lang</code> attributes in the
	case of XML-based documents <a data-link-type="biblio" href="#biblio-xml10">[XML10]</a>. See <a href="http://www.w3.org/International/questions/qa-lang-2or3.html"> "FAQ: Two-letter or three-letter language codes."</a></p>
   <div class="example" id="example-91142d84">
    <a class="self-link" href="#example-91142d84"></a> Examples:
		The two following selectors represent an HTML document that is in
		Belgian French or German. The two next selectors represent <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-q-element" id="ref-for-the-q-element">q</a> quotations in an arbitrary element in Belgian French
		or German. 
<pre>html:lang(fr-be)
html:lang(de)
:lang(fr-be) > q
:lang(de) > q
</pre>
   </div>
   <p class="note" role="note"><span>Note:</span> One difference between <span class="css">:lang(C)</span> and the ''|='' operator
	is that the ''|='' operator only performs a comparison against a given
	attribute on the element, while the <span class="css">:lang(C)</span> pseudo-class
	uses the UAs knowledge of the document’s semantics to perform the
	comparison.</p>
   <div class="example" id="example-c45712e2">
    <a class="self-link" href="#example-c45712e2"></a> In this HTML example, only the BODY matches
		''[lang|=fr]'' (because it has a LANG attribute) but both
		the BODY and the P match <span class="css">:lang(fr)</span> (because both are in
		French). The P does not match the ''[lang|=fr]'' because it
		does not have a LANG attribute. 
<pre>&lt;body lang=fr>
  &lt;p>Je suis français.&lt;/p>
&lt;/body>
</pre>
   </div>
   <div class="example" id="example-c3df9362">
    <a class="self-link" href="#example-c3df9362"></a> Another difference between <span class="css">:lang(C)</span> and the ''|='' operator
		is that <span class="css">:lang(C)</span> performs implicit wildcard matching. 
    <p>For example, <span class="css">:lang(de-DE)</span> will match all of <span class="css">de-DE</span>, <span class="css">de-DE-1996</span>, <span class="css">de-Latn-DE</span>, <span class="css">de-Latf-DE</span>, <span class="css">de-Latn-DE-1996</span>,
		whereas of those ''[lang|=de-DE]<span class="css"> will only match </span>de-DE'' and <span class="css">de-DE-1996</span>.</p>
    <p>To perform wildcard matching on the first subtag (the primary language),
		an asterisk must be used: <span class="css">*-CH</span> will match all of <span class="css">de-CH</span>, <span class="css">it-CH</span>, <span class="css">fr-CH</span>, and <span class="css">rm-CH</span>.</p>
    <p>To select against an element’s lang attribute value
		using this type of language range match,
		use both the attribute selector and language pseudo-class together,
		e.g. <span class="css">[lang]:lang(de-DE)</span>.</p>
   </div>
   <p class="note" role="note"><span>Note:</span> Wildcard language matching and comma-separated lists are new in Level 4.</p>
   <h2 class="heading settled" data-level="8" id="location"><span class="secno">8. </span><span class="content"> Location Pseudo-classes</span><a class="self-link" href="#location"></a></h2>
   <h3 class="heading settled" data-level="8.1" id="the-any-link-pseudo"><span class="secno">8.1. </span><span class="content"> The Hyperlink Pseudo-class: <a class="css" data-link-type="maybe" href="#any-link-pseudo" id="ref-for-any-link-pseudo">:any-link</a></span><a class="self-link" href="#the-any-link-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="any-link-pseudo">:any-link</dfn> pseudo-class represents an element
	that acts as the source anchor of a hyperlink.
	For example, in <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>, any <a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a⑧">a</a>, <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/image-maps.html#the-area-element" id="ref-for-the-area-element">area</a>, or <a data-link-type="element" href="https://svgwg.org/svg2-draft/styling.html#LinkElement" id="ref-for-LinkElement">link</a> elements with an <code>href</code> attribute
	are hyperlinks, and thus match <code>:any-link</code>.
	It matches an element if the element would match either <a class="css" data-link-type="maybe" href="#link-pseudo" id="ref-for-link-pseudo">:link</a> or <a class="css" data-link-type="maybe" href="#visited-pseudo" id="ref-for-visited-pseudo">:visited</a>,
	and is equivalent to <span class="css">:is(:link, :visited)</span>.</p>
   <h3 class="heading settled" data-level="8.2" id="link"><span class="secno">8.2. </span><span class="content"> The Link History Pseudo-classes: <a class="css" data-link-type="maybe" href="#link-pseudo" id="ref-for-link-pseudo①">:link</a> and <a class="css" data-link-type="maybe" href="#visited-pseudo" id="ref-for-visited-pseudo①">:visited</a></span><a class="self-link" href="#link"></a></h3>
   <p>User agents commonly display unvisited <a href="#the-any-link-pseudo">hyperlinks</a> differently from
	previously visited ones. Selectors
	provides the pseudo-classes <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="link-pseudo">:link</dfn> and <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="visited-pseudo">:visited</dfn> to distinguish them:</p>
   <ul>
    <li>The <a class="css" data-link-type="maybe" href="#link-pseudo" id="ref-for-link-pseudo②">:link</a> pseudo-class applies to links that have
		not yet been visited. 
    <li>The <a class="css" data-link-type="maybe" href="#visited-pseudo" id="ref-for-visited-pseudo②">:visited</a> pseudo-class applies once the link has
		been visited by the user. 
   </ul>
   <p>After some amount of time, user agents may choose to return a
	visited link to the (unvisited) <a class="css" data-link-type="maybe" href="#link-pseudo" id="ref-for-link-pseudo③">:link</a> state.</p>
   <p>The two states are mutually exclusive.</p>
   <div class="example" id="example-0fcef6cd">
    <a class="self-link" href="#example-0fcef6cd"></a> The following selector represents links carrying class <code>footnote</code> and already visited: 
<pre>.footnote:visited </pre>
   </div>
   <p>Since it is possible for style sheet authors to abuse the :link and :visited pseudo-classes
	to determine which sites a user has visited without the user’s consent,
	UAs may treat all links as unvisited links
	or implement other measures to preserve the user’s privacy
	while rendering visited and unvisited links differently.</p>
   <h3 class="heading settled" data-level="8.3" id="the-local-link-pseudo"><span class="secno">8.3. </span><span class="content"> The Local Link Pseudo-class: <a class="css" data-link-type="maybe" href="#local-link-pseudo" id="ref-for-local-link-pseudo">:local-link</a></span><a class="self-link" href="#the-local-link-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="local-link-pseudo">:local-link</dfn> pseudo-class
	allows authors to style <a href="#the-any-link-pseudo">hyperlinks</a> based on the users current location within a site.
	It represents an element that is
	the source anchor of a hyperlink whose target’s absolute URL
	matches the element’s own document URL.
	If the hyperlink’s target includes a fragment URL,
	then the fragment URL of the current URL must also match;
	if it does not, then the fragment URL portion of the current URL
	is not taken into account in the comparison.</p>
   <div class="example" id="example-f0a37344">
    <a class="self-link" href="#example-f0a37344"></a> For example, the following rule prevents links targetting the
		current page from being underlined when they are part of the
		navigation list: 
<pre>nav :local-link { text-decoration: none; } </pre>
   </div>
   <p class="note" role="note"><span>Note:</span> The current URL of a page can change as a result of user actions
	such as activating a link targetting a different fragment within the same page;
	or by use of the <code>pushState</code> API;
	as well as by the more obvious actions of navigating to a different page
	or following a redirect (which could be initiated by protocols such as HTTP,
	markup instructions such as <code>&lt;meta http-equiv="..."></code>,
	or scripting instructions ).
	UAs must ensure that <a class="css" data-link-type="maybe" href="#local-link-pseudo" id="ref-for-local-link-pseudo①">:local-link</a>,
	as well as the <a class="css" data-link-type="maybe" href="#target-pseudo" id="ref-for-target-pseudo">:target</a> and <a class="css" data-link-type="maybe" href="#target-within-pseudo" id="ref-for-target-within-pseudo">:target-within</a> pseudo-classes below,
	respond correctly to all such changes in state.</p>
   <h3 class="heading settled" data-level="8.4" id="the-target-pseudo"><span class="secno">8.4. </span><span class="content"> The Target Pseudo-class: <a class="css" data-link-type="maybe" href="#target-pseudo" id="ref-for-target-pseudo①">:target</a></span><a class="self-link" href="#the-target-pseudo"></a></h3>
   <p>In some document languages,
	the document’s URL can further point to specific elements <em>within</em> the document
	via the URL’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment" id="ref-for-concept-url-fragment">fragment</a>.
	The elements pointed to in this way are the target elements of the document.</p>
   <div class="example" id="example-b8c5336f"><a class="self-link" href="#example-b8c5336f"></a> In HTML the fragment points to the element in the page with the same ID.
		The url <code>https://example.com/index.html#section2</code>,
		for example,
		points to the element with <code>id="section2"</code> in the document at <code>https://example.com/index.html</code>. </div>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="target-pseudo">:target</dfn> pseudo-class matches the document’s target elements.
	If the document’s URL has no fragment identifier, then the document has no target elements.</p>
   <div class="example" id="example-8a386e7c">
    <a class="self-link" href="#example-8a386e7c"></a> Example: 
<pre>p.note:target </pre>
    <p>This selector represents a <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element①">p</a></code> element of class <code>note</code> that is the target element of the referring
		URL.</p>
   </div>
   <div class="example" id="example-af403697">
    <a class="self-link" href="#example-af403697"></a> CSS example:
		Here, the <a class="css" data-link-type="maybe" href="#target-pseudo" id="ref-for-target-pseudo②">:target</a> pseudo-class is used to make the
		target element red and place an image before it, if there is one: 
<pre>:target { color : red }
:target::before { content : url(target.png) }
</pre>
   </div>
   <h3 class="heading settled" data-level="8.5" id="the-target-within-pseudo"><span class="secno">8.5. </span><span class="content"> The Target Container Pseudo-class: <a class="css" data-link-type="maybe" href="#target-within-pseudo" id="ref-for-target-within-pseudo①">:target-within</a></span><a class="self-link" href="#the-target-within-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="target-within-pseudo">:target-within</dfn> pseudo-class
	applies to elements for which the <a class="css" data-link-type="maybe" href="#target-pseudo" id="ref-for-target-pseudo③">:target</a> pseudo class applies
	as well as to an element whose descendant in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-scoping-1/#flat-tree" id="ref-for-flat-tree">flat tree</a> (including non-element nodes, such as text nodes)
	matches the conditions for matching <a class="css" data-link-type="maybe" href="#target-within-pseudo" id="ref-for-target-within-pseudo②">:target-within</a>.</p>
   <h3 class="heading settled" data-level="8.6" id="the-scope-pseudo"><span class="secno">8.6. </span><span class="content"> The Reference Element Pseudo-class: <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo⑥">:scope</a></span><a class="self-link" href="#the-scope-pseudo"></a></h3>
   <p>In some contexts, selectors can be matched with an explicit set of <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt=":scope element" id="scope-element">:scope elements</dfn>.
	This is is a (potentially empty) set of elements
	that provide a reference point for selectors to match against,
	such as that specified by the <code>querySelector()</code> call in <a data-link-type="biblio" href="#biblio-dom">[DOM]</a>.</p>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="scope-pseudo">:scope</dfn> pseudo-class represents any element that is a <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element⑥">:scope element</a>.
	If the <span id="ref-for-scope-element⑦">:scope elements</span> are not explicitly specified,
	but the selector is <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector④">scoped</a> and the <a data-link-type="dfn" href="#scoping-root" id="ref-for-scoping-root②">scoping root</a> is an element,
	then <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo⑦">:scope</a> represents the <span id="ref-for-scoping-root③">scoping root</span>;
	otherwise, it represents the root of the document
	(equivalent to <a class="css" data-link-type="maybe" href="#root-pseudo" id="ref-for-root-pseudo">:root</a>).
	Specifications intending for this pseudo-class to match specific elements
	rather than the document’s root element
	must define either a <span id="ref-for-scoping-root④">scoping root</span> (if using <span id="ref-for-scoped-selector⑤">scoped selectors</span>) or an explicit set of <span id="ref-for-scope-element⑧">:scope elements</span>.</p>
   <h2 class="heading settled" data-level="9" id="useraction-pseudos"><span class="secno">9. </span><span class="content"> User Action Pseudo-classes</span><a class="self-link" href="#useraction-pseudos"></a></h2>
   <p>Interactive user interfaces sometimes change the rendering in response to user actions.
	Selectors provides several <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="user action pseudo-class" data-noexport id="user-action-pseudo-class">user action pseudo-classes</dfn> for the selection of an element the user is acting on.
	(In non-interactive user agents, these pseudo-classes are valid, but never match any element.)</p>
   <p>These pseudo-classes are not mutually exclusive.
	An element can match several such pseudo-classes at the same time.</p>
   <div class="example" id="example-eaf585d5">
    <a class="self-link" href="#example-eaf585d5"></a> Examples: 
<pre>a:link    /* unvisited links */
a:visited /* visited links */
a:hover   /* user hovers */
a:active  /* active links */
</pre>
    <p>An example of combining dynamic pseudo-classes:</p>
<pre>a:focus
a:focus:hover
</pre>
    <p>The last selector matches <a data-link-type="element" href="https://svgwg.org/svg2-draft/linking.html#elementdef-a" id="ref-for-elementdef-a⑨">a</a> elements that are in
		the pseudo-class :focus and in the pseudo-class :hover.</p>
   </div>
   <p class="note" role="note"><span>Note:</span> The specifics of hit-testing,
	necessary to know when several of the pseudo-classes defined in this section apply,
	are not yet defined,
	but will be in the future.</p>
   <h3 class="heading settled" data-level="9.1" id="the-hover-pseudo"><span class="secno">9.1. </span><span class="content"> The Pointer Hover Pseudo-class: <a class="css" data-link-type="maybe" href="#hover-pseudo" id="ref-for-hover-pseudo①">:hover</a></span><a class="self-link" href="#the-hover-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="hover-pseudo">:hover</dfn> pseudo-class applies
	while the user designates an element with a pointing device,
	but does not necessarily activate it.
	For example, a visual user agent could apply this pseudo-class
	when the cursor (mouse pointer) hovers over a box generated by the element.
	Interactive user agents that cannot detect hovering due to hardware limitations
	(e.g., a pen device that does not detect hovering)
	are still conforming;
	the selector will simply never match in such a UA.</p>
   <p>An element also matches <a class="css" data-link-type="maybe" href="#hover-pseudo" id="ref-for-hover-pseudo②">:hover</a> if one of its descendants in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-scoping-1/#flat-tree" id="ref-for-flat-tree①">flat tree</a> (including non-element nodes, such as text nodes)
	matches the above conditions.</p>
   <p>Document languages may define additional ways in which an element can match <a class="css" data-link-type="maybe" href="#hover-pseudo" id="ref-for-hover-pseudo③">:hover</a>.
	For example, <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> defines a labeled control element as <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-hover">matching <code>:hover</code></a> when its <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/forms.html#the-label-element" id="ref-for-the-label-element">label</a> is hovered.</p>
   <p class="note" role="note"><span>Note:</span> Since the <a class="css" data-link-type="maybe" href="#hover-pseudo" id="ref-for-hover-pseudo④">:hover</a> state can apply to an element
	because its child is designated by a pointing device,
	it is possible for <span class="css" id="ref-for-hover-pseudo⑤">:hover</span> to apply
	to an element that is not underneath the pointing device.</p>
   <p>The <a class="css" data-link-type="maybe" href="#hover-pseudo" id="ref-for-hover-pseudo⑥">:hover</a> pseudo-class can apply to any pseudo-element.</p>
   <h3 class="heading settled" data-level="9.2" id="the-active-pseudo"><span class="secno">9.2. </span><span class="content"> The Activation Pseudo-class: <a class="css" data-link-type="maybe" href="#active-pseudo" id="ref-for-active-pseudo">:active</a></span><a class="self-link" href="#the-active-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="active-pseudo">:active</dfn> pseudo-class applies while an element
	is being activated by the user. For example, between the times the
	user presses the mouse button and releases it. On systems with more
	than one mouse button, <a class="css" data-link-type="maybe" href="#active-pseudo" id="ref-for-active-pseudo①">:active</a> applies only to the
	primary or primary activation button (typically the "left" mouse
	button), and any aliases thereof.</p>
   <p>There may be document-language or implementation-specific limits on
	which elements can become <a class="css" data-link-type="maybe" href="#active-pseudo" id="ref-for-active-pseudo②">:active</a>.
	For example, <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> defines a <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-active">list of activatable elements</a>.</p>
   <p>An element also matches <a class="css" data-link-type="maybe" href="#active-pseudo" id="ref-for-active-pseudo③">:active</a> if one of its descendants in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-scoping-1/#flat-tree" id="ref-for-flat-tree②">flat tree</a> (including non-element nodes, such as text nodes)
	matches the above conditions.</p>
   <p>Document languages may define additional ways in which an element can match <a class="css" data-link-type="maybe" href="#active-pseudo" id="ref-for-active-pseudo④">:active</a>.</p>
   <p class="note" role="note"><span>Note:</span> An element can be both <a class="css" data-link-type="maybe" href="#visited-pseudo" id="ref-for-visited-pseudo③">:visited</a> and <a class="css" data-link-type="maybe" href="#active-pseudo" id="ref-for-active-pseudo⑤">:active</a> (or <a class="css" data-link-type="maybe" href="#link-pseudo" id="ref-for-link-pseudo④">:link</a> and <span class="css" id="ref-for-active-pseudo⑥">:active</span>).</p>
   <h3 class="heading settled" data-level="9.3" id="the-focus-pseudo"><span class="secno">9.3. </span><span class="content"> The Input Focus Pseudo-class: <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo②">:focus</a></span><a class="self-link" href="#the-focus-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="focus-pseudo">:focus</dfn> pseudo-class applies
	while an element has the focus
	(accepts keyboard or mouse events, or other forms of input).</p>
   <p>There may be document language or implementation specific limits on
	which elements can acquire <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo③">:focus</a>.
	For example, <a data-link-type="biblio" href="#biblio-html">[HTML]</a> defines a list of <a href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area">focusable areas</a>.</p>
   <p>Document languages may define additional ways in which an element can match <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo④">:focus</a>,
	except that the <span class="css" id="ref-for-focus-pseudo⑤">:focus</span> pseudo class must not automatically propagate to the parent element—<wbr>see <a class="css" data-link-type="maybe" href="#focus-within-pseudo" id="ref-for-focus-within-pseudo">:focus-within</a> if matching on the parent is desired.
	(It may still apply to the parent element
	if made to propagate due to other mechanisms,
	but not merely due to being the parent.)</p>
   <p class="issue" id="issue-1416193e"><a class="self-link" href="#issue-1416193e"></a> There’s a desire from authors to propagate <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo⑥">:focus</a> from a form control to its associated <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/forms.html#the-label-element" id="ref-for-the-label-element①">label</a></code> element;
	the main objection seems to be implementation difficulty.
	See <a href="https://github.com/w3c/csswg-drafts/issues/397">CSSWG issue (CSS)</a> and <a href="https://github.com/whatwg/html/issues/1632">WHATWG issue (HTML)</a>.</p>
   <h3 class="heading settled" data-level="9.4" id="the-focus-visible-pseudo"><span class="secno">9.4. </span><span class="content"> The Focus-Indicated Pseudo-class: <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo">:focus-visible</a></span><span id="the-focusring-pseudo"></span><span id="focus-ring-pseudo"></span><a class="self-link" href="#the-focus-visible-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="focus-visible-pseudo">:focus-visible</dfn> pseudo-class applies
	while an element matches the <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo⑦">:focus</a> pseudo-class <em>and</em> the user agent determines via heuristics
	that the focus should be made evident on the element.</p>
   <p class="note" role="note"><span>Note:</span> The intent of <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo①">:focus-visible</a> is
	to allow authors to provide <em>clearly identifiable</em> focus styles
	which are visible when a user is likely to need to understand where focus is,
	and not visible in other cases.</p>
   <div class="example" id="example-c40d8011">
    <a class="self-link" href="#example-c40d8011"></a> In this example,
		all focusable elements get a strong yellow outline on <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo②">:focus-visible</a>,
		and links get both a yellow outline and a yellow background on <span class="css" id="ref-for-focus-visible-pseudo③">:focus-visible</span>.
		These styles are consistent throughout the page and are easily visible
		due to their bold styling,
		but do not appear unless the user is likely to need to understand
		where page focus is. 
<pre class="highlight"><c- f>:root </c-><c- p>{</c->
  <c- k>--focus-gold</c-><c- p>:</c-> #ffbf47<c- p>;</c->
<c- p>}</c->

<c- f>:focus-visible  </c-><c- p>{</c->
  <c- k>outline</c-><c- p>:</c-> <c- m>3</c-><c- l>px</c-> solid <c- nf>var</c-><c- p>(</c->--focus-gold<c- p>);</c->
<c- p>}</c->

<c- f>a:focus-visible </c-><c- p>{</c->
  <c- k>background-color</c-><c- p>:</c-> <c- nf>var</c-><c- p>(</c->--focus-gold<c- p>);</c->
<c- p>}</c->
</pre>
   </div>
   <p>User agents can choose their own heuristics for when to match <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo④">:focus-visible</a>;
	however, the following (non-normative) suggestions can be used as a starting point:</p>
   <ul>
    <li data-md>
     <p>If a user has expressed a preference
(such as via a system preference or a browser setting)
to always see a visible focus indicator,
the user agent should honor this
by having <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo⑤">:focus-visible</a> always match on the active element,
regardless of any other factors.
(Another option may be for the user agent to show its own focus indicator
regardless of author styles.)</p>
    <li data-md>
     <p>Any element which supports keyboard input
(such as an <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element">input</a></code> element,
or any other element
which may trigger a virtual keyboard to be shown on focus
if a physical keyboard is not present)
should <strong>always</strong> match <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo⑥">:focus-visible</a> when focused.</p>
    <li data-md>
     <p>If the user interacts with the page via the keyboard,
the currently focused element should match <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo⑦">:focus-visible</a> (i.e. keyboard usage may change whether this pseudo-class matches
even if it doesn’t affect <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo⑧">:focus</a>).</p>
    <li data-md>
     <p>If the user interacts with the page via a pointing device,
such that the focus is moved to a new element
which does <em>not</em> support user input,
the newly focused element
should <strong>not</strong> match <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo⑧">:focus-visible</a>.</p>
    <li data-md>
     <p>If the active element matches <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo⑨">:focus-visible</a>,
and a script causes focus to move elsewhere,
the newly focused element should match <span class="css" id="ref-for-focus-visible-pseudo①⓪">:focus-visible</span>.</p>
    <li data-md>
     <p>Conversely, if the active element does not match <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo①①">:focus-visible</a>,
and a script causes focus to move elsewhere,
the newly focused element should <strong>not</strong> match <span class="css" id="ref-for-focus-visible-pseudo①②">:focus-visible</span>.</p>
   </ul>
   <p>User agents should also use <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo①③">:focus-visible</a> to specify the default focus style,
	so that authors using <span class="css" id="ref-for-focus-visible-pseudo①④">:focus-visible</span> will not also need to disable
	the default <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo⑨">:focus</a> style.</p>
   <div class="example" id="example-cd595a08">
    <a class="self-link" href="#example-cd595a08"></a> In this example,
	authors use a <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo⑦">:not()</a> pseudo-class to remove default user agent focus styling
	if <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo①⑤">:focus-visible</a> is supported,
	and provide enhanced focus styling via <span class="css" id="ref-for-focus-visible-pseudo①⑥">:focus-visible</span>. 
<pre class="highlight"><c- f>:focus:not(:focus-visible) </c-><c- p>{</c->
  <c- k>outline</c-><c- p>:</c-> <c- m>0</c-><c- p>;</c->
<c- p>}</c->

<c- f>:focus-visible </c-><c- p>{</c->
  <c- k>outline</c-><c- p>:</c-> <c- m>3</c-><c- l>px</c-> solid <c- nf>var</c-><c- p>(</c->--focus-gold<c- p>);</c->
<c- p>}</c->
</pre>
   </div>
   <h3 class="heading settled" data-level="9.5" id="the-focus-within-pseudo"><span class="secno">9.5. </span><span class="content"> The Focus Container Pseudo-class: <a class="css" data-link-type="maybe" href="#focus-within-pseudo" id="ref-for-focus-within-pseudo①">:focus-within</a></span><a class="self-link" href="#the-focus-within-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="focus-within-pseudo">:focus-within</dfn> pseudo-class
	applies to any element for which the <a class="css" data-link-type="maybe" href="#focus-pseudo" id="ref-for-focus-pseudo①⓪">:focus</a> pseudo class applies
	as well as to an element whose descendant in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-scoping-1/#flat-tree" id="ref-for-flat-tree③">flat tree</a> (including non-element nodes, such as text nodes)
	matches the conditions for matching <span class="css" id="ref-for-focus-pseudo①①">:focus</span>.</p>
   <h2 class="heading settled" data-level="10" id="time-pseudos"><span class="secno">10. </span><span class="content"> Time-dimensional Pseudo-classes</span><a class="self-link" href="#time-pseudos"></a></h2>
   <p>These pseudo-classes classify elements with respect to the
	currently-displayed or active position in some timeline, such as
	during speech rendering of a document, or during the display of
	a video using WebVTT to render subtitles.</p>
   <p>CSS does not define this timeline;
	the host language must do so.
	If there is no timeline defined for an element,
	these pseudo-classes must not match the element.</p>
   <p class="note" role="note"><span>Note:</span> Ancestors of a <a class="css" data-link-type="maybe" href="#current-pseudo" id="ref-for-current-pseudo①">:current</a> element are also <span class="css" id="ref-for-current-pseudo②">:current</span>,
	but ancestors of a <a class="css" data-link-type="maybe" href="#past-pseudo" id="ref-for-past-pseudo">:past</a> or <a class="css" data-link-type="maybe" href="#future-pseudo" id="ref-for-future-pseudo">:future</a> element are not necessarily <span class="css" id="ref-for-past-pseudo①">:past</span> or <span class="css" id="ref-for-future-pseudo①">:future</span> as well.
	A given element matches at most one of <span class="css" id="ref-for-current-pseudo③">:current</span>, <span class="css" id="ref-for-past-pseudo②">:past</span>, or <span class="css" id="ref-for-future-pseudo②">:future</span>.</p>
   <h3 class="heading settled" data-level="10.1" id="the-current-pseudo"><span class="secno">10.1. </span><span class="content"> The Current-element Pseudo-class: <a class="css" data-link-type="maybe" href="#current-pseudo" id="ref-for-current-pseudo④">:current</a></span><a class="self-link" href="#the-current-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="current-pseudo">:current</dfn> pseudo-class represents the
	element, or an ancestor of the element, that is currently being displayed.</p>
   <p>Its alternate form <dfn class="css" data-dfn-type="selector" data-export id="selectordef-current">:current()<a class="self-link" href="#selectordef-current"></a></dfn>, like <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①③">:is()</a>,
	takes a list of <a data-link-type="dfn" href="#compound" id="ref-for-compound③⓪">compound selectors</a> as its argument: it represents the <a class="css" data-link-type="maybe" href="#current-pseudo" id="ref-for-current-pseudo⑤">:current</a> element that matches the argument or, if that does
	not match, the innermost ancestor of the <span class="css" id="ref-for-current-pseudo⑥">:current</span> element
	that does. (If neither the <span class="css" id="ref-for-current-pseudo⑦">:current</span> element nor its ancestors
	match the argument, then the selector does not represent anything.)</p>
   <div class="example" id="example-34db2617">
    <a class="self-link" href="#example-34db2617"></a> For example, the following rule will highlight whichever paragraph
		or list item is being read aloud in a speech rendering of the document: 
<pre>:current(p, li, dt, dd) {
  background: yellow;
}
</pre>
   </div>
   <h3 class="heading settled" data-level="10.2" id="the-past-pseudo"><span class="secno">10.2. </span><span class="content"> The Past-element Pseudo-class: <a class="css" data-link-type="maybe" href="#past-pseudo" id="ref-for-past-pseudo③">:past</a></span><a class="self-link" href="#the-past-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="past-pseudo">:past</dfn> pseudo-class represents any element that is
	defined to occur entirely prior to a <a class="css" data-link-type="maybe" href="#current-pseudo" id="ref-for-current-pseudo⑧">:current</a> element.
	For example, the WebVTT spec defines the <a class="css" data-link-type="maybe" href="#past-pseudo" id="ref-for-past-pseudo④">:past</a> pseudo-class <a href="http://dev.w3.org/html5/webvtt/#the-past-and-future-pseudo-classes">relative to the current playback position of a media element</a>.
	If a time-based order of elements is not defined by the document language,
	then this represents any element that is a (possibly indirect) previous
	sibling of a <span class="css" id="ref-for-current-pseudo⑨">:current</span> element.</p>
   <h3 class="heading settled" data-level="10.3" id="the-future-pseudo"><span class="secno">10.3. </span><span class="content"> The Future-element Pseudo-class: <a class="css" data-link-type="maybe" href="#future-pseudo" id="ref-for-future-pseudo③">:future</a></span><a class="self-link" href="#the-future-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="future-pseudo">:future</dfn> pseudo-class represents any element that is
	defined to occur entirely after a <a class="css" data-link-type="maybe" href="#current-pseudo" id="ref-for-current-pseudo①⓪">:current</a> element.
	For example, the WebVTT spec defines the <a class="css" data-link-type="maybe" href="#future-pseudo" id="ref-for-future-pseudo④">:future</a> pseudo-class <a href="http://dev.w3.org/html5/webvtt/#the-past-and-future-pseudo-classes">relative to the current playback position of a media element</a>.
	If a time-based order of elements is not defined by the document language,
	then this represents any element that is a (possibly indirect) next
	sibling of a <span class="css" id="ref-for-current-pseudo①①">:current</span> element.</p>
   <h2 class="heading settled" data-level="11" id="resource-pseudos"><span class="secno">11. </span><span class="content"> Resource State Pseudos</span><a class="self-link" href="#resource-pseudos"></a></h2>
   <p>The pseudo-classes in this section apply to elements that represent loaded resources,
	particularly images/videos,
	and allow authors to select them based on some quality of their state.</p>
   <h3 class="heading settled" data-level="11.1" id="video-state"><span class="secno">11.1. </span><span class="content"> Video/Audio Play State: the <a class="css" data-link-type="maybe" href="#selectordef-playing" id="ref-for-selectordef-playing">:playing</a> and <a class="css" data-link-type="maybe" href="#selectordef-paused" id="ref-for-selectordef-paused">:paused</a> pseudo-classes</span><a class="self-link" href="#video-state"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="selectordef-playing">:playing</dfn> pseudo-class represents an element
	representing an audio, video, or similar resource
	that is capable of being “played” or “paused”,
	when that element is “playing”.
	(This includes both when the element is explicitly playing,
	and when it’s temporarily stopped for some reason not connected to user intent,
	but will automatically resume when that reason is resolved,
	such as a “buffering” state.)</p>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="selectordef-paused">:paused</dfn> pseudo-class represents the same elements,
	but instead match when the element is <em>not</em> “playing”.
	(This includes both an explicit “paused” state,
	and other non-playing states like “loaded, hasn’t been activated yet”, etc.)</p>
   <h2 class="heading settled" data-level="12" id="input-pseudos"><span class="secno">12. </span><span class="content"> The Input Pseudo-classes</span><a class="self-link" href="#input-pseudos"></a></h2>
   <p>The pseudo-classes in this section mostly apply to elements that take user input,
	such as HTML’s <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element①">input</a> element.</p>
   <h3 class="heading settled" data-level="12.1" id="input-states"><span class="secno">12.1. </span><span class="content"> Input Control States</span><a class="self-link" href="#input-states"></a></h3>
   <h4 class="heading settled" data-level="12.1.1" id="enableddisabled"><span class="secno">12.1.1. </span><span class="content"> The <a class="css" data-link-type="maybe" href="#enabled-pseudo" id="ref-for-enabled-pseudo">:enabled</a> and <a class="css" data-link-type="maybe" href="#disabled-pseudo" id="ref-for-disabled-pseudo">:disabled</a> Pseudo-classes</span><a class="self-link" href="#enableddisabled"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="enabled-pseudo">:enabled</dfn> pseudo-class represents
	user interface elements that are in an enabled state;
	such elements must have a corresponding disabled state.</p>
   <p>Conversely, the <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="disabled-pseudo">:disabled</dfn> pseudo-class represents
	user interface elements that are in a disabled state;
	such elements must have a corresponding enabled state.</p>
   <p>What constitutes an enabled state, a disabled state, and a user interface
	element is host-language-dependent. In a typical document most elements will be
	neither <a class="css" data-link-type="maybe" href="#enabled-pseudo" id="ref-for-enabled-pseudo①">:enabled</a> nor <a class="css" data-link-type="maybe" href="#disabled-pseudo" id="ref-for-disabled-pseudo①">:disabled</a>.
	For example, <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> defines <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-enabled">non-disabled interactive elements</a> to be <span class="css" id="ref-for-enabled-pseudo②">:enabled</span>,
	and any such elements that are <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-enabled">explicitly disabled</a> to be <span class="css" id="ref-for-disabled-pseudo②">:disabled</span>.</p>
   <p class="note" role="note"><span>Note:</span> CSS properties that might affect a user’s ability
	to interact with a given user interface element do not affect whether it
	matches <a class="css" data-link-type="maybe" href="#enabled-pseudo" id="ref-for-enabled-pseudo③">:enabled</a> or <a class="css" data-link-type="maybe" href="#disabled-pseudo" id="ref-for-disabled-pseudo③">:disabled</a>; e.g., the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display" id="ref-for-propdef-display">display</a> and <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visufx.html#propdef-visibility" id="ref-for-propdef-visibility">visibility</a> properties have no effect
	on the enabled/disabled state of an element.</p>
   <h4 class="heading settled" data-level="12.1.2" id="rw-pseudos"><span class="secno">12.1.2. </span><span class="content"> The Mutability Pseudo-classes: <a class="css" data-link-type="maybe" href="#read-only-pseudo" id="ref-for-read-only-pseudo">:read-only</a> and <a class="css" data-link-type="maybe" href="#read-write-pseudo" id="ref-for-read-write-pseudo①">:read-write</a></span><a class="self-link" href="#rw-pseudos"></a></h4>
   <p>An element matches <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="read-write-pseudo">:read-write</dfn> if it is user-alterable,
	as defined by the document language.
	Otherwise, it is <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="read-only-pseudo">:read-only</dfn>.</p>
   <p>For example, in <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> a <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-read-only">non-disabled non-readonly <code>&lt;input></code> element</a> is <a class="css" data-link-type="maybe" href="#read-write-pseudo" id="ref-for-read-write-pseudo②">:read-write</a>,
	as is any element with the <code>contenteditable</code> attribute set to the true state.</p>
   <h4 class="heading settled" data-level="12.1.3" id="placeholder"><span class="secno">12.1.3. </span><span class="content"> The Placeholder-shown Pseudo-class: <a class="css" data-link-type="maybe" href="#placeholder-shown-pseudo" id="ref-for-placeholder-shown-pseudo">:placeholder-shown</a></span><a class="self-link" href="#placeholder"></a></h4>
   <p>Input elements can sometimes show placeholder text
	as a hint to the user on what to type in.
	See, for example, the <code>placeholder</code> attribute in <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>.
	The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="placeholder-shown-pseudo">:placeholder-shown</dfn> pseudo-class
	matches an input element that is showing such placeholder text,
	whether that text is given by an attribute or a real element,
	or is otherwise implied by the UA.</p>
   <div class="example" id="example-8b59d4ec"><a class="self-link" href="#example-8b59d4ec"></a> For example, according to the semantics of <a data-link-type="biblio" href="#biblio-html">[HTML]</a> the <code><a data-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/input.html#attr-input-placeholder" id="ref-for-attr-input-placeholder">placeholder</a></code> attribute on the <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element②">input</a></code> element
		provide placeholder text,
		as does the first <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element" id="ref-for-the-option-element">option</a></code> element of a <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element" id="ref-for-the-select-element">select</a></code> under certain conditions.
		The <a class="css" data-link-type="maybe" href="#placeholder-shown-pseudo" id="ref-for-placeholder-shown-pseudo①">:placeholder-shown</a> class thus applies
		whenever such placeholder text is shown. </div>
   <h4 class="heading settled" data-level="12.1.4" id="the-default-pseudo"><span class="secno">12.1.4. </span><span class="content"> The Default-option Pseudo-class: <a class="css" data-link-type="maybe" href="#default-pseudo" id="ref-for-default-pseudo">:default</a></span><a class="self-link" href="#the-default-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="default-pseudo">:default</dfn> pseudo-class applies to the one or more UI elements
	that are the default among a set of similar elements.  Typically applies to
	context menu items, buttons and select lists/menus.</p>
   <p>One example is the default submit button among a set of buttons.
	Another example is the default option from a popup menu.
	In a select-many group (such as for pizza toppings), multiple elements can match <a class="css" data-link-type="maybe" href="#default-pseudo" id="ref-for-default-pseudo①">:default</a>.
	For example, <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> defines that <span class="css" id="ref-for-default-pseudo②">:default</span> matches <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-default">the “default button” in a form,
	the initially-selected <code>&lt;option></code>(s) in a <code>&lt;select></code>,
	and a few other elements.</a></p>
   <h3 class="heading settled" data-level="12.2" id="input-value-states"><span class="secno">12.2. </span><span class="content"> Input Value States</span><a class="self-link" href="#input-value-states"></a></h3>
   <h4 class="heading settled" data-level="12.2.1" id="checked"><span class="secno">12.2.1. </span><span class="content"> The Selected-option Pseudo-class: <a class="css" data-link-type="maybe" href="#checked-pseudo" id="ref-for-checked-pseudo">:checked</a></span><a class="self-link" href="#checked"></a></h4>
   <p>Radio and checkbox elements can be toggled by the user.
	Some menu items are “checked” when the user selects them.
	When such elements are toggled “on”
	the <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="checked-pseudo">:checked</dfn> pseudo-class applies.
	For example, <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> defines that <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-checked">checked checkboxes, radio buttons, and selected <code>&lt;option></code> elements</a> match <a class="css" data-link-type="maybe" href="#checked-pseudo" id="ref-for-checked-pseudo①">:checked</a>.</p>
   <p>While the <a class="css" data-link-type="maybe" href="#checked-pseudo" id="ref-for-checked-pseudo②">:checked</a> pseudo-class is dynamic in nature,
	and can altered by user action,
	since it can also be based on the presence of semantic attributes in the document
	(such as the <code>selected</code> and <code>checked</code> attributes in <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>),
	it applies to all media.</p>
   <div class="example" id="example-a6c4964c">
    <a class="self-link" href="#example-a6c4964c"></a> An unchecked checkbox can be selected by using the negation
		pseudo-class: 
<pre>input[type=checkbox]:not(:checked)</pre>
   </div>
   <h4 class="heading settled" data-level="12.2.2" id="indeterminate"><span class="secno">12.2.2. </span><span class="content"> The Indeterminate-value Pseudo-class: <a class="css" data-link-type="maybe" href="#indetermine-pseudo" id="ref-for-indetermine-pseudo">:indeterminate</a></span><a class="self-link" href="#indeterminate"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="indetermine-pseudo">:indeterminate</dfn> pseudo-class applies to UI elements whose
	value is in an indeterminate state.
	For example, radio and checkbox elements can be toggled between checked and unchecked states,
	but are sometimes in an indeterminate state, neither checked nor unchecked.
	Similarly a progress meter can be in an indeterminate state when the percent completion is unknown.
	For example, <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a> defines how <a href="https://html.spec.whatwg.org/multipage/semantics-other.html#selector-indeterminate">checkboxes</a> can be made to match <a class="css" data-link-type="maybe" href="#indetermine-pseudo" id="ref-for-indetermine-pseudo①">:indeterminate</a>.</p>
   <p>Like the <a class="css" data-link-type="maybe" href="#checked-pseudo" id="ref-for-checked-pseudo③">:checked</a> pseudo-class, <a class="css" data-link-type="maybe" href="#indetermine-pseudo" id="ref-for-indetermine-pseudo②">:indeterminate</a> applies to all media. Components of a radio-group initialized with no
	pre-selected choice, for example, would be <span class="css" id="ref-for-indetermine-pseudo③">:indeterminate</span> even in a static display.</p>
   <h3 class="heading settled" data-level="12.3" id="ui-validity"><span class="secno">12.3. </span><span class="content"> Input Value-checking</span><a class="self-link" href="#ui-validity"></a></h3>
   <h4 class="heading settled" data-level="12.3.1" id="blank"><span class="secno">12.3.1. </span><span class="content"> The Empty-Value Pseudo-class: <a class="css" data-link-type="maybe" href="#blank-pseudo" id="ref-for-blank-pseudo">:blank</a></span><a class="self-link" href="#blank"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="blank-pseudo">:blank</dfn> pseudo-class
	applies to user-input elements whose input value is empty
	(consists of the empty string or otherwise null input).</p>
   <div class="example" id="example-e34400f8"><a class="self-link" href="#example-e34400f8"></a> Examples of <a class="css" data-link-type="maybe" href="#blank-pseudo" id="ref-for-blank-pseudo①">:blank</a> user-input elements would be
		a <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element" id="ref-for-the-textarea-element">textarea</a></code> element whose contents are empty,
		or an <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element③">input</a></code> field whose value is empty.
		Note that the value under consideration here is the value
		that would be submitted
		(see <a href="https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#a-form-control’s-value">A form control’s value</a> in <a data-link-type="biblio" href="#biblio-html">[HTML]</a>),
		which in HTML does not necessarily correspond to the value
		of the element’s <code><a data-link-type="element-sub" href="https://html.spec.whatwg.org/multipage/input.html#attr-input-value" id="ref-for-attr-input-value">value</a></code> attribute. </div>
   <p class="note" role="note"><span>Note:</span> This selector is at-risk.</p>
   <h4 class="heading settled" data-level="12.3.2" id="validity-pseudos"><span class="secno">12.3.2. </span><span class="content"> The Validity Pseudo-classes: <a class="css" data-link-type="maybe" href="#valid-pseudo" id="ref-for-valid-pseudo①">:valid</a> and <a class="css" data-link-type="maybe" href="#invalid-pseudo" id="ref-for-invalid-pseudo">:invalid</a></span><a class="self-link" href="#validity-pseudos"></a></h4>
   <p>An element is <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="valid-pseudo">:valid</dfn> or <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="invalid-pseudo">:invalid</dfn> when its contents or value is, respectively,
	valid or invalid with respect to data validity semantics defined by the document language
	(e.g. <a data-link-type="biblio" href="#biblio-xforms11">[XFORMS11]</a> or <a data-link-type="biblio" href="#biblio-html5">[HTML5]</a>).
	An element which lacks data validity semantics is neither <a class="css" data-link-type="maybe" href="#valid-pseudo" id="ref-for-valid-pseudo②">:valid</a> nor <a class="css" data-link-type="maybe" href="#invalid-pseudo" id="ref-for-invalid-pseudo①">:invalid</a>.</p>
   <p class="note" role="note"><span>Note:</span> There is a difference between an element which has no constraints,
	and thus would always be <a class="css" data-link-type="maybe" href="#valid-pseudo" id="ref-for-valid-pseudo③">:valid</a>,
	and one which has no data validity semantics at all,
	and thus is neither <span class="css" id="ref-for-valid-pseudo④">:valid</span> nor <a class="css" data-link-type="maybe" href="#invalid-pseudo" id="ref-for-invalid-pseudo②">:invalid</a>.
	In HTML, for example, an <code>&lt;input type="text"></code> element may have no constraints,
	but a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element②">p</a> element has no validity semantics at all,
	and so it never matches either of these pseudo-classes.</p>
   <h4 class="heading settled" data-level="12.3.3" id="range-pseudos"><span class="secno">12.3.3. </span><span class="content"> The Range Pseudo-classes: <a class="css" data-link-type="maybe" href="#in-range-pseudo" id="ref-for-in-range-pseudo">:in-range</a> and <a class="css" data-link-type="maybe" href="#out-of-range-pseudo" id="ref-for-out-of-range-pseudo">:out-of-range</a></span><a class="self-link" href="#range-pseudos"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="in-range-pseudo">:in-range</dfn> and <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="out-of-range-pseudo">:out-of-range</dfn> pseudo-classes
	apply only to elements that have range limitations.  An element is <a class="css" data-link-type="maybe" href="#in-range-pseudo" id="ref-for-in-range-pseudo①">:in-range</a> or <a class="css" data-link-type="maybe" href="#out-of-range-pseudo" id="ref-for-out-of-range-pseudo①">:out-of-range</a> when the value
	that the element is bound to is in range or out of range with respect
	to its range limits as defined by the document language. An element
	that lacks data range limits or is not a form control is neither <span class="css" id="ref-for-in-range-pseudo②">:in-range</span> nor <span class="css" id="ref-for-out-of-range-pseudo②">:out-of-range</span>.
	E.g. a slider element with a value of 11 presented as a slider control
	that only represents the values from 1-10 is :out-of-range.  Another
	example is a menu element with a value of "E" that happens to be
	presented in a popup menu that only has choices "A", "B" and "C".</p>
   <h4 class="heading settled" data-level="12.3.4" id="opt-pseudos"><span class="secno">12.3.4. </span><span class="content"> The Optionality Pseudo-classes: <a class="css" data-link-type="maybe" href="#required-pseudo" id="ref-for-required-pseudo">:required</a> and <a class="css" data-link-type="maybe" href="#optional-pseudo" id="ref-for-optional-pseudo">:optional</a></span><a class="self-link" href="#opt-pseudos"></a></h4>
   <p>A form element is <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="required-pseudo">:required</dfn> or <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="optional-pseudo">:optional</dfn> if a value for it is, respectively, required or optional before the
	form it belongs to can be validly submitted. Elements that are not
	form elements are neither required nor optional.</p>
   <h4 class="heading settled" data-level="12.3.5" id="user-pseudos"><span class="secno">12.3.5. </span><span class="content"> The User-interaction Pseudo-class: <a class="css" data-link-type="maybe" href="#user-invalid-pseudo" id="ref-for-user-invalid-pseudo">:user-invalid</a></span><a class="self-link" href="#user-pseudos"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="user-invalid-pseudo">:user-invalid</dfn> pseudo-class
	represents an element with incorrect input, but only <em>after</em> the user has significantly interacted with it.
	The <a class="css" data-link-type="maybe" href="#user-invalid-pseudo" id="ref-for-user-invalid-pseudo①">:user-invalid</a> pseudo-class
	must match an <a class="css" data-link-type="maybe" href="#invalid-pseudo" id="ref-for-invalid-pseudo③">:invalid</a>, <a class="css" data-link-type="maybe" href="#out-of-range-pseudo" id="ref-for-out-of-range-pseudo③">:out-of-range</a>, or blank-but-<a class="css" data-link-type="maybe" href="#required-pseudo" id="ref-for-required-pseudo①">:required</a> elements
	between the time the user has attempted to submit the form
	and before the user has interacted again with the form element.
	User-agents may allow it to match such elements at other times,
	as would be appropriate for highlighting an error to the user.
	For example, a UA may choose to have <span class="css" id="ref-for-user-invalid-pseudo②">:user-invalid</span> match
	an <span class="css" id="ref-for-invalid-pseudo④">:invalid</span> element once the user has typed some text into it
	and changed the focus to another element,
	and to stop matching only after the user has successfully corrected the input.</p>
   <div class="example" id="example-42eddba4">
    <a class="self-link" href="#example-42eddba4"></a> For example, the input in the following document fragment
		would match <a class="css" data-link-type="maybe" href="#invalid-pseudo" id="ref-for-invalid-pseudo⑤">:invalid</a> as soon as the page is loaded
		(because it the initial value violates the max-constraint),
		but it won’t match <a class="css" data-link-type="maybe" href="#user-invalid-pseudo" id="ref-for-user-invalid-pseudo③">:user-invalid</a> until the user significantly interacts with the element,
		or attempts to submit the form it’s part of. 
<pre>&lt;form>
  &lt;label>
    Volume:
    &lt;input name='vol' type=number min=0 max=10 value=11>
  &lt;/label>
  ...
&lt;/form>
</pre>
   </div>
   <p class="issue" id="issue-b776312b"><a class="self-link" href="#issue-b776312b"></a> Cross-check with <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/%3A-moz-ui-invalid"><span class="css">:-moz-ui-invalid</span></a>.</p>
   <p class="issue" id="issue-fcbee641"><a class="self-link" href="#issue-fcbee641"></a> Add <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/%3A-moz-ui-valid">:-moz-ui-valid</a> as <span class="css">:user-valid</span> per WG resolution.</p>
   <p class="issue" id="issue-a71d9d5b"><a class="self-link" href="#issue-a71d9d5b"></a> Evaluate proposed <a href="https://lists.w3.org/Archives/Public/www-style/2014Feb/0511.html">:dirty pseudo-class</a></p>
   <p class="issue" id="issue-df919919"><a class="self-link" href="#issue-df919919"></a> Clarify that this (and <a class="css" data-link-type="maybe" href="#invalid-pseudo" id="ref-for-invalid-pseudo⑥">:invalid</a>/<a class="css" data-link-type="maybe" href="#valid-pseudo" id="ref-for-valid-pseudo⑤">:valid</a>) can apply to form and fieldset elements.</p>
   <h2 class="heading settled" data-level="13" id="structural-pseudos"><span class="secno">13. </span><span class="content"> Tree-Structural pseudo-classes</span><a class="self-link" href="#structural-pseudos"></a></h2>
   <p>Selectors introduces the concept of <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="structural-pseudo-classes">structural pseudo-classes</dfn> to permit selection based on extra information that lies in
	the document tree but cannot be represented by other simple selectors or
	combinators.</p>
   <p>Standalone text and other non-element
	nodes are not counted when calculating the position of an element in the list
	of children of its parent. When calculating the position of an element in
	the list of children of its parent, the index numbering starts at 1.</p>
   <p>The <a data-link-type="dfn" href="#structural-pseudo-classes" id="ref-for-structural-pseudo-classes①">structural pseudo-classes</a> only apply to elements in the document tree;
	they must never match <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②③">pseudo-elements</a>.</p>
   <h3 class="heading settled" data-level="13.1" id="the-root-pseudo"><span class="secno">13.1. </span><span class="content"> <a class="css" data-link-type="maybe" href="#root-pseudo" id="ref-for-root-pseudo①">:root</a> pseudo-class</span><a class="self-link" href="#the-root-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="root-pseudo">:root</dfn> pseudo-class represents an element that is
	the root of the document.</p>
   <p>For example, in a DOM document,
	the <a class="css" data-link-type="maybe" href="#root-pseudo" id="ref-for-root-pseudo②">:root</a> pseudo-class matches the root element of the <a class="idl-code" data-link-type="interface" href="https://dom.spec.whatwg.org/#document" id="ref-for-document">Document</a> object.
	In HTML, this would be the <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/semantics.html#the-html-element" id="ref-for-the-html-element">html</a> element
	(unless scripting has been used to modify the document).</p>
   <h3 class="heading settled" data-level="13.2" id="the-empty-pseudo"><span class="secno">13.2. </span><span class="content"> <a class="css" data-link-type="maybe" href="#empty-pseudo" id="ref-for-empty-pseudo">:empty</a> pseudo-class</span><a class="self-link" href="#the-empty-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="empty-pseudo">:empty</dfn> pseudo-class represents
	an element that has no children
	except, optionally, <a data-link-type="dfn" href="https://drafts.csswg.org/css-text-3/#white-space" id="ref-for-white-space">document white space characters</a>.
	In terms of the document tree,
	only element nodes and content nodes
	(such as <a data-link-type="biblio" href="#biblio-dom">[DOM]</a> text nodes, and entity references)
	whose data has a non-zero length must be considered as affecting emptiness;
	comments, processing instructions, and other nodes
	must not affect whether an element is considered empty or not.</p>
   <div class="example" id="example-3846287b">
    <a class="self-link" href="#example-3846287b"></a> Examples: <span class="css">p:empty</span> is a valid representation of the <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element③">p</a></code> elements
		in the following HTML fragment: 
<pre class="html">&lt;p>&lt;/p>
&lt;p>
&lt;p> &lt;/p>
&lt;p>&lt;/p>
</pre>
    <p><span class="css">div:empty</span> is not a valid representation of the <code>&lt;div></code> elements
		in the following fragment:</p>
<pre class="html">&lt;div>text&lt;/div>
&lt;div>&lt;p>&lt;/p>&lt;/div>
&lt;div>&amp;nbsp;&lt;/div>
&lt;div>&lt;p>bla&lt;/p>&lt;/div>
&lt;div>this is not &lt;p>:empty&lt;/p>&lt;/div>
</pre>
   </div>
   <p class="note" role="note"><span>Note:</span> In Level 2 and Level 3 of Selectors, <a class="css" data-link-type="maybe" href="#empty-pseudo" id="ref-for-empty-pseudo①">:empty</a> did not match elements that contained only white space.
	This was changed so that that—<wbr>given white space is largely collapsible in HTML
	and is therefore used for source code formatting,
	and especially because elements with omitted end tags
	are likely to absorb such white space into their DOM text contents—<wbr>elements which authors perceive of as empty
	can be selected by this selector, as they expect.</p>
   <h3 class="heading settled" data-level="13.3" id="child-index"><span class="secno">13.3. </span><span class="content"> Child-indexed Pseudo-classes</span><a class="self-link" href="#child-index"></a></h3>
   <p>The pseudo-classes defined in this section select elements
	based on their index amongst their <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-sibling" id="ref-for-concept-tree-inclusive-sibling">inclusive siblings</a>.</p>
   <p class="note" role="note"><span>Note:</span> Selectors 3 described these selectors as selecting elements based on their index in the child list of their parents.
	(This description survives in the name of this very section, and the names of several of the pseudo-classes.)
	As there was no reason to exclude them from matching elements without parents,
	or with non-element parents,
	they have been rephrased to refer to an element’s relative index amongst its siblings.</p>
   <h4 class="heading settled" data-level="13.3.1" id="the-nth-child-pseudo"><span class="secno">13.3.1. </span><span class="content"> <a class="css" data-link-type="maybe" href="#nth-child-pseudo" id="ref-for-nth-child-pseudo">:nth-child()</a> pseudo-class</span><a class="self-link" href="#the-nth-child-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export data-lt=":nth-child()" id="nth-child-pseudo">:nth-child(<var>An+B</var> [of <var>S</var>]? )</dfn> pseudo-class notation represents elements that
	are among <var>An+B</var>th elements
	from the list composed of
	their <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-sibling" id="ref-for-concept-tree-inclusive-sibling①">inclusive siblings</a> that match the <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list⑨">selector list</a> <var>S</var>.
	If <var>S</var> is omitted,
	it defaults to <span class="css">*|*</span>.</p>
   <p>The <var>An+B</var> notation and its interpretation
	are defined in <a href="https://drafts.csswg.org/css-syntax-3/#anb-microsyntax">CSS Syntax 3 §6 The An+B microsyntax</a>;
	it represents any index <var>i</var> = <var>A</var><var>n</var> + <var>B</var> for any non-negative integer <var>n</var>.</p>
   <p class="note" role="note"><span>Note:</span> For these purposes, the list of elements is <b>1-indexed</b>;
	that is, the first child of an element has index 1, and will be matched by <span class="css">:nth-child(2n+1)</span>,
	because when <code>n=0</code> the expression evaluates to <span class="css">1</span>.</p>
   <p>For example, this selector could address every other row in a table,
	and could be used to alternate the color of paragraph text in a cycle of four.</p>
   <div class="example" id="example-b8d691c9">
    <a class="self-link" href="#example-b8d691c9"></a> Examples: 
<pre>:nth-child(even)   /* represents the 2nd, 4th, 6th, etc elements
:nth-child(10n-1)  /* represents the 9th, 19th, 29th, etc elements */
:nth-child(10n+9)  /* Same */
:nth-child(10n+-1) /* Syntactically invalid, and would be ignored */
</pre>
   </div>
   <p class="note" role="note"><span>Note:</span> The specificity of the <a class="css" data-link-type="maybe" href="#nth-child-pseudo" id="ref-for-nth-child-pseudo①">:nth-child()</a> pseudo-class is
	the specificity of a single pseudo-class plus,
	if <var>S</var> is specified,
	the specificity of the most specific <a data-link-type="dfn" href="#complex" id="ref-for-complex⑥">complex selector</a> in <var>S</var>.
	See <a href="#specificity-rules">§ 16 Calculating a selector’s specificity</a>.
	Thus <span class="css">S:nth-child(An+B)</span> and <span class="css">:nth-child(An+B of S)</span> have the exact same specificity,
	although they do differ in behavior
	(see example below).</p>
   <div class="example" id="example-3c07f717">
    <a class="self-link" href="#example-3c07f717"></a> By passing a selector argument,
		we can select the Nth element that matches that selector.
		For example, the following selector matches the first three “important” list items,
		denoted by the <span class="css">.important</span> class: 
<pre>:nth-child(-n+3 of li.important)</pre>
    <p>Note that this is different from moving the selector outside of the function, like:</p>
<pre>li.important:nth-child(-n+3)</pre>
    <p>This selector instead just selects the first three children
		if they also happen to be "important" list items.</p>
   </div>
   <div class="example" id="example-48f80a26">
    <a class="self-link" href="#example-48f80a26"></a> Here’s another example of using the selector argument,
		to ensure that zebra-striping a table works correctly. 
    <p>Normally, to zebra-stripe a table’s rows,
		an author would use CSS similar to the following:</p>
<pre>tr {
  background: white;
}
tr:nth-child(even) {
  background: silver;
}
</pre>
    <p>However, if some of the rows are hidden and not displayed,
		this can break up the pattern,
		causing multiple adjacent rows to have the same background color.
		Assuming that rows are hidden with the <span class="css">[hidden]</span> attribute in HTML,
		the following CSS would zebra-stripe the table rows robustly,
		maintaining a proper alternating background
		regardless of which rows are hidden:</p>
<pre>tr {
  background: white;
}
tr:nth-child(even of :not([hidden])) {
  background: silver;
}
</pre>
   </div>
   <h4 class="heading settled" data-level="13.3.2" id="the-nth-last-child-pseudo"><span class="secno">13.3.2. </span><span class="content"> <a class="css" data-link-type="maybe" href="#nth-last-child-pseudo" id="ref-for-nth-last-child-pseudo">:nth-last-child()</a> pseudo-class</span><a class="self-link" href="#the-nth-last-child-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export data-lt=":nth-last-child()" id="nth-last-child-pseudo">:nth-last-child(<var>An+B</var> [of <var>S</var>]? )</dfn> pseudo-class notation represents elements that
	are among <var>An+B</var>th elements
	from the list composed of
	their <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-sibling" id="ref-for-concept-tree-inclusive-sibling②">inclusive siblings</a> that match the <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list①⓪">selector list</a> <var>S</var>,
	counting backwards from the end.
	If <var>S</var> is omitted,
	it defaults to <span class="css">*|*</span>.</p>
   <p class="note" role="note"><span>Note:</span> The specificity of the <a class="css" data-link-type="maybe" href="#nth-last-child-pseudo" id="ref-for-nth-last-child-pseudo①">:nth-last-child()</a> pseudo-class,
	like the <a class="css" data-link-type="maybe" href="#nth-child-pseudo" id="ref-for-nth-child-pseudo②">:nth-child()</a> pseudo-class,
	combines the specificity of a regular pseudo-class
	with that of its selector argument <var>S</var>.
	See <a href="#specificity-rules">§ 16 Calculating a selector’s specificity</a>.</p>
   <p>The CSS Syntax Module <a data-link-type="biblio" href="#biblio-css3syn">[CSS3SYN]</a> defines the <a href="https://drafts.csswg.org/css-syntax/#anb"><var>An+B</var> notation</a>.</p>
   <div class="example" id="example-bee68ad4">
    <a class="self-link" href="#example-bee68ad4"></a> Examples: 
<pre>tr:nth-last-child(-n+2)    /* represents the two last rows of an HTML table */

foo:nth-last-child(odd)    /* represents all odd foo elements in their parent element,
                              counting from the last one */
</pre>
   </div>
   <h4 class="heading settled" data-level="13.3.3" id="the-first-child-pseudo"><span class="secno">13.3.3. </span><span class="content"> <a class="css" data-link-type="maybe" href="#first-child-pseudo" id="ref-for-first-child-pseudo">:first-child</a> pseudo-class</span><a class="self-link" href="#the-first-child-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="first-child-pseudo">:first-child</dfn> pseudo-class
	represents an element that if first among its <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-sibling" id="ref-for-concept-tree-inclusive-sibling③">inclusive siblings</a>.
	Same as <span class="css">:nth-child(1)</span>.</p>
   <div class="example" id="example-72934891">
    <a class="self-link" href="#example-72934891"></a> Examples:
		The following selector represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element④">p</a> element that is
		the first child of a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-div-element" id="ref-for-the-div-element①">div</a> element: 
<pre>div > p:first-child</pre>
    <p>This selector can represent the <code>p</code> inside the <code>div</code> of the following fragment:</p>
<pre>&lt;p> The last P before the note.&lt;/p>
&lt;div class="note">
   &lt;p> The first P inside the note.&lt;/p>
&lt;/div>
</pre>
    <p>but cannot represent the second <code>p</code> in the following fragment:</p>
<pre>&lt;p> The last P before the note.&lt;/p>
&lt;div class="note">
   &lt;h2> Note &lt;/h2>
   &lt;p> The first P inside the note.&lt;/p>
&lt;/div>
</pre>
    <p>The following two selectors are usually equivalent:</p>
<pre>* > a:first-child /* a is first child of any element */
a:first-child /* Same (assuming a is not the root element) */
</pre>
   </div>
   <h4 class="heading settled" data-level="13.3.4" id="the-last-child-pseudo"><span class="secno">13.3.4. </span><span class="content"> <a class="css" data-link-type="maybe" href="#last-child-pseudo" id="ref-for-last-child-pseudo">:last-child</a> pseudo-class</span><a class="self-link" href="#the-last-child-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="last-child-pseudo">:last-child</dfn> pseudo-class
	represents an element that is last among its <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-inclusive-sibling" id="ref-for-concept-tree-inclusive-sibling④">inclusive siblings</a>.
	Same as <span class="css">:nth-last-child(1)</span>.</p>
   <div class="example" id="example-48137186">
    <a class="self-link" href="#example-48137186"></a> Example:
		The following selector represents a list item <code>li</code> that
		is the last child of an ordered list <code>ol</code>. 
<pre>ol > li:last-child</pre>
   </div>
   <h4 class="heading settled" data-level="13.3.5" id="the-only-child-pseudo"><span class="secno">13.3.5. </span><span class="content"> <a class="css" data-link-type="maybe" href="#only-child-pseudo" id="ref-for-only-child-pseudo">:only-child</a> pseudo-class</span><a class="self-link" href="#the-only-child-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="only-child-pseudo">:only-child</dfn> pseudo-class
	represents an element that has no siblings.
	Same as <span class="css">:first-child:last-child</span> or <span class="css">:nth-child(1):nth-last-child(1)</span>,
	but with a lower specificity.</p>
   <h3 class="heading settled" data-level="13.4" id="typed-child-index"><span class="secno">13.4. </span><span class="content"> Typed Child-indexed Pseudo-classes</span><a class="self-link" href="#typed-child-index"></a></h3>
   <p>The pseudo-elements in this section are similar to the <a href="#child-index">Child Index Pseudo-classes</a>,
	but they resolve based on an element’s index <strong>among elements of the same <a href="#type-selectors">type (tag name)</a></strong> in their sibling list.</p>
   <h4 class="heading settled" data-level="13.4.1" id="the-nth-of-type-pseudo"><span class="secno">13.4.1. </span><span class="content"> <a class="css" data-link-type="maybe" href="#nth-of-type-pseudo" id="ref-for-nth-of-type-pseudo">:nth-of-type()</a> pseudo-class</span><a class="self-link" href="#the-nth-of-type-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export data-lt=":nth-of-type()" id="nth-of-type-pseudo">:nth-of-type(<var>An+B</var>)</dfn> pseudo-class notation
	represents the same elements that would be matched by <span class="css">:nth-child(|An+B| of <var>S</var>)</span>,
	where <var>S</var> is a <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector①②">type selector</a> and namespace prefix matching the element in question.
	For example,
	when considering whether an HTML <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element" id="ref-for-the-img-element">img</a></code> element matches this <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class①③">pseudo-class</a>,
	the <var>S</var> in question is <span class="css">html|img</span> (assuming an appropriate <code>html</code> namespace is declared).</p>
   <div class="example" id="example-3d09bf4d">
    <a class="self-link" href="#example-3d09bf4d"></a> CSS example:
		This allows an author to alternate the position of floated images: 
<pre>img:nth-of-type(2n+1) { float: right; }
img:nth-of-type(2n) { float: left; }
</pre>
   </div>
   <p class="note" role="note"><span>Note:</span> If the type of the element is known ahead of time,
	this pseudo-class is equivalent to using <a class="css" data-link-type="maybe" href="#nth-child-pseudo" id="ref-for-nth-child-pseudo③">:nth-child()</a> with a type selector.
	That is, <span class="css">img:nth-of-type(2)</span> is equivalent to <span class="css">*:nth-child(2 of img)</span>.</p>
   <h4 class="heading settled" data-level="13.4.2" id="the-nth-last-of-type-pseudo"><span class="secno">13.4.2. </span><span class="content"> <a class="css" data-link-type="maybe" href="#nth-last-of-type-pseudo" id="ref-for-nth-last-of-type-pseudo">:nth-last-of-type()</a> pseudo-class</span><a class="self-link" href="#the-nth-last-of-type-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export data-lt=":nth-last-of-type()" id="nth-last-of-type-pseudo">:nth-last-of-type(<var>An+B</var>)</dfn> pseudo-class notation
	represents the same elements that would be matched by <span class="css">:nth-last-child(|An+B| of <var>S</var>)</span>,
	where <var>S</var> is a <a data-link-type="dfn" href="#type-selector" id="ref-for-type-selector①③">type selector</a> and namespace prefix matching the element in question.
	For example,
	when considering whether an HTML <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element" id="ref-for-the-img-element①">img</a></code> element matches this <a data-link-type="dfn" href="#pseudo-class" id="ref-for-pseudo-class①④">pseudo-class</a>,
	the <var>S</var> in question is <span class="css">html|img</span> (assuming an appropriate <code>html</code> namespace is declared).</p>
   <div class="example" id="example-b89418c8">
    <a class="self-link" href="#example-b89418c8"></a> Example:
		To represent all <code>h2</code> children of an XHTML <code>body</code> except the first and last, one could use the
		following selector: 
<pre>body > h2:nth-of-type(n+2):nth-last-of-type(n+2) </pre>
    <p>In this case, one could also use <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo⑧">:not()</a>, although the
		selector ends up being just as long:</p>
<pre>body > h2:not(:first-of-type):not(:last-of-type) </pre>
   </div>
   <h4 class="heading settled" data-level="13.4.3" id="the-first-of-type-pseudo"><span class="secno">13.4.3. </span><span class="content"> <a class="css" data-link-type="maybe" href="#first-of-type-pseudo" id="ref-for-first-of-type-pseudo">:first-of-type</a> pseudo-class</span><a class="self-link" href="#the-first-of-type-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="first-of-type-pseudo">:first-of-type</dfn> pseudo-class
	represents the same element as <span class="css">:nth-of-type(1)</span>.</p>
   <div class="example" id="example-16f73753">
    <a class="self-link" href="#example-16f73753"></a> Example:
		The following selector represents a definition title <code>dt</code> inside a definition list <code>dl</code>, this <code>dt</code> being the first of its type in the list of children of
		its parent element. 
<pre>dl dt:first-of-type</pre>
    <p>It is a valid description for the first two <code>dt</code> elements in the following example but not for the third one:</p>
<pre>&lt;dl>
  &lt;dt>gigogne&lt;/dt>
  &lt;dd>
    &lt;dl>
      &lt;dt>fusée&lt;/dt>
      &lt;dd>multistage rocket&lt;/dd>
      &lt;dt>table&lt;/dt>
      &lt;dd>nest of tables&lt;/dd>
    &lt;/dl>
  &lt;/dd>
&lt;/dl>
</pre>
   </div>
   <h4 class="heading settled" data-level="13.4.4" id="the-last-of-type-pseudo"><span class="secno">13.4.4. </span><span class="content"> <a class="css" data-link-type="maybe" href="#last-of-type-pseudo" id="ref-for-last-of-type-pseudo">:last-of-type</a> pseudo-class</span><a class="self-link" href="#the-last-of-type-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="last-of-type-pseudo">:last-of-type</dfn> pseudo-class
	represents the same element as <span class="css">:nth-last-of-type(1)</span>.</p>
   <div class="example" id="example-fee30007">
    <a class="self-link" href="#example-fee30007"></a> Example:
		The following selector represents the last data cell <code>td</code> of a table row <code>tr</code>. 
<pre>tr > td:last-of-type</pre>
   </div>
   <h4 class="heading settled" data-level="13.4.5" id="the-only-of-type-pseudo"><span class="secno">13.4.5. </span><span class="content"> <a class="css" data-link-type="maybe" href="#only-of-type-pseudo" id="ref-for-only-of-type-pseudo">:only-of-type</a> pseudo-class</span><a class="self-link" href="#the-only-of-type-pseudo"></a></h4>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export id="only-of-type-pseudo">:only-of-type</dfn> pseudo-class
	represents the same element as <span class="css">:first-of-type:last-of-type</span>.</p>
   <h2 class="heading settled" data-level="14" id="combinators"><span class="secno">14. </span><span class="content"> Combinators</span><a class="self-link" href="#combinators"></a></h2>
   <h3 class="heading settled" data-level="14.1" id="descendant-combinators"><span class="secno">14.1. </span><span class="content"> Descendant combinator (<code> </code>)</span><a class="self-link" href="#descendant-combinators"></a></h3>
   <p>At times, authors may want selectors to describe an element that is
	the descendant of another element in the document tree (e.g., "an <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-em-element" id="ref-for-the-em-element">em</a> element that is contained within an <a data-link-type="element">H1</a> element").
	The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="descendant-combinator">descendant combinator</dfn> expresses such a relationship.</p>
   <p>A descendant combinator is whitespace that separates two <a data-link-type="dfn" href="#compound" id="ref-for-compound③①">compound selectors</a>.</p>
   <p>A selector of the form <span class="css">A B</span> represents an element <code>B</code> that is an
	arbitrary descendant of some ancestor element <code>A</code>.</p>
   <div class="example" id="example-13246ba1">
    <a class="self-link" href="#example-13246ba1"></a> Examples:
		For example, consider the following selector: 
<pre>h1 em</pre>
    <p>It represents an <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-em-element" id="ref-for-the-em-element①">em</a> element being the descendant of
		an <a data-link-type="element">h1</a> element. It is a correct and valid, but partial,
		description of the following fragment:</p>
<pre>&lt;h1>This &lt;span class="myclass">headline
is &lt;em>very&lt;/em> important&lt;/span>&lt;/h1>
</pre>
    <p>The following selector:</p>
<pre>div * p</pre>
    <p>represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element⑤">p</a> element that is a grandchild or later
		descendant of a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-div-element" id="ref-for-the-div-element②">div</a> element. Note the whitespace on
		either side of the "*" is not part of the universal selector; the
		whitespace is a combinator indicating that the <code>div</code> must be the
		ancestor of some element, and that that element must be an ancestor
		of the <code>p</code>.
		The following selector, which combines descendant combinators and <a href="#attribute-selectors">attribute selectors</a>, represents an
		element that (1) has the <code>href</code> attribute set and (2) is
		inside a <code>p</code> that is itself inside a <code>div</code>:</p>
<pre>div p *[href]</pre>
   </div>
   <h3 class="heading settled" data-level="14.2" id="child-combinators"><span class="secno">14.2. </span><span class="content"> Child combinator (<code>></code>)</span><a class="self-link" href="#child-combinators"></a></h3>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="child-combinator">child combinator</dfn> describes a childhood relationship
	between two elements. A child combinator is made of the
	"greater-than sign" (U+003E, <dfn class="css" data-dfn-type="selector" data-export id="selectordef-child">><a class="self-link" href="#selectordef-child"></a></dfn>) code point and
	separates two <a data-link-type="dfn" href="#compound" id="ref-for-compound③②">compound selectors</a>.</p>
   <div class="example" id="example-63e612ba">
    <a class="self-link" href="#example-63e612ba"></a> Examples:
		The following selector represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element⑥">p</a> element that is
		child of <code>body</code>: 
<pre>body > p</pre>
    <p>The following example combines descendant combinators and child
		combinators.</p>
<pre>div ol>li p</pre>
    <p>It represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element⑦">p</a> element that is a descendant of an <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-li-element" id="ref-for-the-li-element">li</a> element; the <span id="ref-for-the-li-element①">li</span> element must be the
		child of an <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-ol-element" id="ref-for-the-ol-element①">ol</a> element; the <span id="ref-for-the-ol-element②">ol</span> element must
		be a descendant of a <code>div</code>. Notice that the optional white
		space around the ">" combinator has been left out.</p>
   </div>
   <p>For information on selecting the first child of an element,
	please see the section on the <a class="css" data-link-type="maybe" href="#first-child-pseudo" id="ref-for-first-child-pseudo①">:first-child</a> pseudo-class above.</p>
   <h3 class="heading settled" data-level="14.3" id="adjacent-sibling-combinators"><span class="secno">14.3. </span><span class="content"> Next-sibling combinator (<code>+</code>)</span><a class="self-link" href="#adjacent-sibling-combinators"></a></h3>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="next-sibling-combinator">next-sibling combinator</dfn> is made of the “plus sign”
	(U+002B, <dfn class="css" data-dfn-type="selector" data-export id="selectordef-adjacent">+<a class="self-link" href="#selectordef-adjacent"></a></dfn>) code point that separates two <a data-link-type="dfn" href="#compound" id="ref-for-compound③③">compound selectors</a>.
	The elements represented by the two <span id="ref-for-compound③④">compound selectors</span> share the same parent in the document tree
	and the element represented by the first <span id="ref-for-compound③⑤">compound selector</span> immediately precedes the element represented by the second one.
	Non-element nodes (e.g. text between elements)
	are ignored when considering the adjacency of elements.</p>
   <div class="example" id="example-0f0597d9">
    <a class="self-link" href="#example-0f0597d9"></a> Examples:
		The following selector represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element" id="ref-for-the-p-element⑧">p</a> element
		immediately following a <a data-link-type="element">math</a> element: 
<pre>math + p</pre>
    <p>The following selector is conceptually similar to the one in the
		previous example, except that it adds an attribute selector — it
		adds a constraint to the <a data-link-type="element">h1</a> element, that it must have <code>class="opener"</code>:</p>
<pre>h1.opener + h2</pre>
   </div>
   <h3 class="heading settled" data-level="14.4" id="general-sibling-combinators"><span class="secno">14.4. </span><span class="content"> Subsequent-sibling combinator (<code>~</code>)</span><a class="self-link" href="#general-sibling-combinators"></a></h3>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="subsequent-sibling-combinator">subsequent-sibling combinator</dfn> is made of the "tilde"
	(U+007E, <dfn class="css" data-dfn-type="selector" data-export id="selectordef-sibling">~<a class="self-link" href="#selectordef-sibling"></a></dfn>) code point that separates two <a data-link-type="dfn" href="#compound" id="ref-for-compound③⑥">compound selectors</a>.
	The elements represented by the two <span id="ref-for-compound③⑦">compound selectors</span> share
	the same parent in the document tree and the element represented by
	the first compound selector precedes (not necessarily immediately) the element
	represented by the second one.</p>
   <div class="example" id="example-ae614b62">
    <a class="self-link" href="#example-ae614b62"></a> 
<pre>h1 ~ pre</pre>
    <p>represents a <a data-link-type="element" href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element" id="ref-for-the-pre-element">pre</a> element following an <code>h1</code>. It
		is a correct and valid, but partial, description of:</p>
<pre>&lt;h1>Definition of the function a&lt;/h1>
&lt;p>Function a(x) has to be applied to all figures in the table.&lt;/p>
&lt;pre>function a(x) = 12x/13.5&lt;/pre>
</pre>
   </div>
   <h2 class="heading settled" data-level="15" id="table-pseudos"><span class="secno">15. </span><span class="content"> Grid-Structural Selectors</span><a class="self-link" href="#table-pseudos"></a></h2>
   <p>The double-association of a cell in a 2D grid (to its row and column)
	cannot be represented by parentage in a hierarchical markup language.
	Only one of those associations can be represented hierarchically: the
	other must be explicitly or implicitly defined in the document language
	semantics. In both HTML and DocBook, two of the most common hierarchical
	markup languages, the markup is row-primary (that is, the row associations
	are represented hierarchically); the columns must be implied.
	To be able to represent such implied column-based relationships, the <a data-link-type="dfn" href="#column-combinator" id="ref-for-column-combinator">column combinator</a> and the <a class="css" data-link-type="maybe" href="#nth-col-pseudo" id="ref-for-nth-col-pseudo">:nth-col()</a> and <a class="css" data-link-type="maybe" href="#nth-last-col-pseudo" id="ref-for-nth-last-col-pseudo">:nth-last-col()</a> pseudo-classes
	are defined.
	In a column-primary format, these pseudo-classes match against row associations instead.</p>
   <h3 class="heading settled" data-level="15.1" id="the-column-combinator"><span class="secno">15.1. </span><span class="content"> Column combinator (<code>||</code>)</span><a class="self-link" href="#the-column-combinator"></a></h3>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="column-combinator">column combinator</dfn>, which consists of two pipes (<dfn class="css" data-dfn-type="selector" data-export id="selectordef-column">||<a class="self-link" href="#selectordef-column"></a></dfn>)
	represents the relationship of a column element
	to a cell element belonging to the column it represents.
	Column membership is determined based on the semantics of the document language only:
	whether and how the elements are presented is not considered.
	If a cell element belongs to more than one column,
	it is represented by a selector indicating membership in any of those columns.</p>
   <div class="example" id="example-60f47339">
    <a class="self-link" href="#example-60f47339"></a> The following example makes cells C, E, and G gray. 
<pre>col.selected || td {
  background: gray;
  color: white;
  font-weight: bold;
}
</pre>
<pre>&lt;table>
  &lt;col span="2">
  &lt;col class="selected">
  &lt;tr>&lt;td>A &lt;td>B &lt;td>C
  &lt;tr>&lt;td colspan="2">D &lt;td>E
  &lt;tr>&lt;td>F &lt;td colspan="2">G
&lt;/table>
</pre>
   </div>
   <h3 class="heading settled" data-level="15.2" id="the-nth-col-pseudo"><span class="secno">15.2. </span><span class="content"> <a class="css" data-link-type="maybe" href="#nth-col-pseudo" id="ref-for-nth-col-pseudo①">:nth-col()</a> pseudo-class</span><a class="self-link" href="#the-nth-col-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export data-lt=":nth-col()" id="nth-col-pseudo">:nth-col(<var>An+B</var>)</dfn> pseudo-class notation represents a cell element belonging to a column
	that has <var>An+B</var>-1 columns <strong>before</strong> it, for any positive
	integer or zero value of <code>n</code>. Column membership is determined
	based on the semantics of the document language only: whether and how the
	elements are presented is not considered. If a cell element belongs to
	more than one column, it is represented by a selector indicating any of
	those columns.</p>
   <p>The CSS Syntax Module <a data-link-type="biblio" href="#biblio-css3syn">[CSS3SYN]</a> defines the <a href="https://drafts.csswg.org/css-syntax/#anb"><var>An+B</var> notation</a>.</p>
   <h3 class="heading settled" data-level="15.3" id="the-nth-last-col-pseudo"><span class="secno">15.3. </span><span class="content"> <a class="css" data-link-type="maybe" href="#nth-last-col-pseudo" id="ref-for-nth-last-col-pseudo①">:nth-last-col()</a> pseudo-class</span><a class="self-link" href="#the-nth-last-col-pseudo"></a></h3>
   <p>The <dfn class="dfn-paneled css" data-dfn-type="selector" data-export data-lt=":nth-last-col()" id="nth-last-col-pseudo">:nth-last-col(<var>An+B</var>)</dfn> pseudo-class notation represents a cell element belonging to a column
	that has <var>An+B</var>-1 columns <strong>after</strong> it, for any positive
	integer or zero value of <code>n</code>. Column membership is determined
	based on the semantics of the document language only: whether and how the
	elements are presented is not considered. If a cell element belongs to
	more than one column, it is represented by a selector indicating any of
	those columns.</p>
   <p>The CSS Syntax Module <a data-link-type="biblio" href="#biblio-css3syn">[CSS3SYN]</a> defines the <a href="https://drafts.csswg.org/css-syntax/#anb"><var>An+B</var> notation</a>.</p>
   <h2 class="heading settled" data-level="16" id="specificity-rules"><span class="secno">16. </span><span class="content"> Calculating a selector’s specificity</span><a class="self-link" href="#specificity-rules"></a></h2>
   <p>A selector’s <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="specificity">specificity</dfn> is calculated for a given element as follows:</p>
   <ul>
    <li>count the number of ID selectors in the selector (= <var>A</var>) 
    <li>count the number of class selectors, attributes selectors, and pseudo-classes in the selector (= <var>B</var>) 
    <li>count the number of type selectors and pseudo-elements in the selector (= <var>C</var>) 
    <li>ignore the universal selector 
   </ul>
   <p>If the selector is a <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list①①">selector list</a>,
	this number is calculated for each selector in the list.
	For a given matching process against the list, the specificity in effect
	is that of the most specific selector in the list that matches.</p>
   <p>A few pseudo-classes provide “evaluation contexts” for other selectors,
	and so have their specificity defined specially:</p>
   <ul>
    <li> The specificity of an <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①④">:is()</a>, <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo⑨">:not()</a>, or <a class="css" data-link-type="maybe" href="#has-pseudo" id="ref-for-has-pseudo②">:has()</a> pseudo-class
			is replaced by the specificity of
			the most specific <a data-link-type="dfn" href="#complex" id="ref-for-complex⑦">complex selector</a> in its <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list①②">selector list</a> argument. 
    <li> Analogously, the specificity of an <a class="css" data-link-type="maybe" href="#nth-child-pseudo" id="ref-for-nth-child-pseudo④">:nth-child()</a> or <a class="css" data-link-type="maybe" href="#nth-last-child-pseudo" id="ref-for-nth-last-child-pseudo②">:nth-last-child()</a> selector
			is the specificity of the pseudo class itself (counting as one pseudo-class selector)
			plus the specificity of
			the most specific <a data-link-type="dfn" href="#complex" id="ref-for-complex⑧">complex selector</a> in its <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list①③">selector list</a> argument (if any). 
    <li> The specificity of a <a class="css" data-link-type="maybe" href="#where-pseudo" id="ref-for-where-pseudo②">:where()</a> pseudo-class is replaced by zero. 
   </ul>
   <div class="example" id="example-bd54871c">
    <a class="self-link" href="#example-bd54871c"></a> For example: 
    <ul>
     <li> <span class="css">:is(em, #foo)</span> has
				a specificity of (1,0,0)—<wbr>like an ID selector (<span class="css">#foo</span>)—<wbr>when matched against any of <code>&lt;em></code>, <code>&lt;p id=foo></code>, or <code>&lt;em id=foo></code>. 
     <li> <span class="css">.qux:where(em, #foo#bar#baz)</span> has
				a specificity of (0,1,0):
				only the <span class="css">.qux</span> outside the <a class="css" data-link-type="maybe" href="#where-pseudo" id="ref-for-where-pseudo③">:where()</a> contributes to selector specificity. 
     <li> <span class="css">:nth-child(even of li, .item)</span> has
				a specificity of (0,2,0)—<wbr>like a class selector (<span class="css">.item</span>) plus a pseudo-class—<wbr>when matched against any of <code>&lt;li></code>, <code>&lt;ul class=item></code>, or <code>&lt;li class=item id=foo></code>. 
     <li> <span class="css">:not(em, strong#foo)</span> has
				a specificity of (1,0,1)—<wbr>like a tag selector (<span class="css">strong</span>) combined with an ID selector (<span class="css">#foo</span>)—<wbr>when matched against any element. 
    </ul>
   </div>
   <p>Specificities are compared by comparing the three components in order:
	the specificity with a larger <var>A</var> value is more specific;
	if the two <var>A</var> values are tied,
	then the specificity with a larger <var>B</var> value is more specific;
	if the two <var>B</var> values are also tied,
	then the specificity with a larger <var>C</var> value is more specific;
	if all the values are tied,
	the two specificities are equal.</p>
   <p>Due to storage limitations,
	implementations may have limitations on the size of <var>A</var>, <var>B</var>, or <var>C</var>.
	If so, values higher than the limit must be clamped to that limit,
	and not overflow.</p>
   <div class="example" id="example-d97bd125">
    <a class="self-link" href="#example-d97bd125"></a> Examples: 
<pre>*               /* a=0 b=0 c=0 */
LI              /* a=0 b=0 c=1 */
UL LI           /* a=0 b=0 c=2 */
UL OL+LI        /* a=0 b=0 c=3 */
H1 + *[REL=up]  /* a=0 b=1 c=1 */
UL OL LI.red    /* a=0 b=1 c=3 */
LI.red.level    /* a=0 b=2 c=1 */
#x34y           /* a=1 b=0 c=0 */
#s12:not(FOO)   /* a=1 b=0 c=1 */
.foo :is(.bar, #baz)
                /* a=1 b=1 c=0 */
</pre>
   </div>
   <p class="note" role="note"><span>Note:</span> Repeated occurrences of the
	same simple selector are allowed and do increase specificity.</p>
   <p class="note" role="note"><span>Note:</span> The specificity of the styles
	specified in an HTML <code>style</code> attribute <a href="https://www.w3.org/TR/css-style-attr/#interpret">is described in CSS Style Attributes</a>. <a data-link-type="biblio" href="#biblio-cssstyleattr">[CSSSTYLEATTR]</a></p>
   <h2 class="heading settled" data-level="17" id="grammar"><span class="secno">17. </span><span class="content"> Grammar</span><span id="formal-syntax"></span><a class="self-link" href="#grammar"></a></h2>
   <p>Selectors are <a data-link-type="dfn" href="https://drafts.csswg.org/css-syntax-3/#css-parse-something-according-to-a-css-grammar" id="ref-for-css-parse-something-according-to-a-css-grammar">parsed</a> according to the following grammar:</p>
<pre class="prod"><dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-selector-list">&lt;selector-list></dfn> = <a class="production" data-link-type="type" href="#typedef-complex-selector-list" id="ref-for-typedef-complex-selector-list">&lt;complex-selector-list></a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-complex-selector-list">&lt;complex-selector-list></dfn> = <a class="production" data-link-type="type" href="#typedef-complex-selector" id="ref-for-typedef-complex-selector①">&lt;complex-selector></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-comma" id="ref-for-mult-comma">#</a>

<dfn data-dfn-type="type" data-export id="typedef-compound-selector-list">&lt;compound-selector-list><a class="self-link" href="#typedef-compound-selector-list"></a></dfn> = <a class="production" data-link-type="type" href="#typedef-compound-selector" id="ref-for-typedef-compound-selector①">&lt;compound-selector></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-comma" id="ref-for-mult-comma①">#</a>

<dfn data-dfn-type="type" data-export id="typedef-simple-selector-list">&lt;simple-selector-list><a class="self-link" href="#typedef-simple-selector-list"></a></dfn> = <a class="production" data-link-type="type" href="#typedef-simple-selector" id="ref-for-typedef-simple-selector①">&lt;simple-selector></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-comma" id="ref-for-mult-comma②">#</a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-relative-selector-list">&lt;relative-selector-list></dfn> = <a class="production" data-link-type="type" href="#typedef-relative-selector" id="ref-for-typedef-relative-selector①">&lt;relative-selector></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-comma" id="ref-for-mult-comma③">#</a>


<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-complex-selector">&lt;complex-selector></dfn> = <a class="production" data-link-type="type" href="#typedef-compound-selector" id="ref-for-typedef-compound-selector②">&lt;compound-selector></a> [ <a class="production" data-link-type="type" href="#typedef-combinator" id="ref-for-typedef-combinator">&lt;combinator></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt">?</a> <a class="production" data-link-type="type" href="#typedef-compound-selector" id="ref-for-typedef-compound-selector③">&lt;compound-selector></a> ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-zero-plus" id="ref-for-mult-zero-plus">*</a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-relative-selector">&lt;relative-selector></dfn> = <a class="production" data-link-type="type" href="#typedef-combinator" id="ref-for-typedef-combinator①">&lt;combinator></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt①">?</a> <a class="production" data-link-type="type" href="#typedef-complex-selector" id="ref-for-typedef-complex-selector②">&lt;complex-selector></a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-compound-selector">&lt;compound-selector></dfn> = [ <a class="production" data-link-type="type" href="#typedef-type-selector" id="ref-for-typedef-type-selector">&lt;type-selector></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt②">?</a> <a class="production" data-link-type="type" href="#typedef-subclass-selector" id="ref-for-typedef-subclass-selector">&lt;subclass-selector></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-zero-plus" id="ref-for-mult-zero-plus①">*</a>
                        [ <a class="production" data-link-type="type" href="#typedef-pseudo-element-selector" id="ref-for-typedef-pseudo-element-selector">&lt;pseudo-element-selector></a> <a class="production" data-link-type="type" href="#typedef-pseudo-class-selector" id="ref-for-typedef-pseudo-class-selector">&lt;pseudo-class-selector></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-zero-plus" id="ref-for-mult-zero-plus②">*</a> ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-zero-plus" id="ref-for-mult-zero-plus③">*</a> ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-req" id="ref-for-mult-req">!</a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-simple-selector">&lt;simple-selector></dfn> = <a class="production" data-link-type="type" href="#typedef-type-selector" id="ref-for-typedef-type-selector①">&lt;type-selector></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one">|</a> <a class="production" data-link-type="type" href="#typedef-subclass-selector" id="ref-for-typedef-subclass-selector①">&lt;subclass-selector></a>


<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-combinator">&lt;combinator></dfn> = '>' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①">|</a> '+' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one②">|</a> '~' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one③">|</a> [ '|' '|' ]

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-type-selector">&lt;type-selector></dfn> = <a class="production" data-link-type="type" href="#typedef-wq-name" id="ref-for-typedef-wq-name">&lt;wq-name></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one④">|</a> <a class="production" data-link-type="type" href="#typedef-ns-prefix" id="ref-for-typedef-ns-prefix">&lt;ns-prefix></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt③">?</a> '*'

<dfn class="dfn-paneled" data-dfn-type="type" data-noexport id="typedef-ns-prefix">&lt;ns-prefix></dfn> = [ <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token②">&lt;ident-token></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one⑤">|</a> '*' ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt④">?</a> '|'

<dfn class="dfn-paneled" data-dfn-type="type" data-noexport id="typedef-wq-name">&lt;wq-name></dfn> = <a class="production" data-link-type="type" href="#typedef-ns-prefix" id="ref-for-typedef-ns-prefix①">&lt;ns-prefix></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt⑤">?</a> <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token③">&lt;ident-token></a>

<dfn class="dfn-paneled" data-dfn-type="type" data-noexport id="typedef-subclass-selector">&lt;subclass-selector></dfn> = <a class="production" data-link-type="type" href="#typedef-id-selector" id="ref-for-typedef-id-selector">&lt;id-selector></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one⑥">|</a> <a class="production" data-link-type="type" href="#typedef-class-selector" id="ref-for-typedef-class-selector">&lt;class-selector></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one⑦">|</a>
                      <a class="production" data-link-type="type" href="#typedef-attribute-selector" id="ref-for-typedef-attribute-selector">&lt;attribute-selector></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one⑧">|</a> <a class="production" data-link-type="type" href="#typedef-pseudo-class-selector" id="ref-for-typedef-pseudo-class-selector①">&lt;pseudo-class-selector></a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-id-selector">&lt;id-selector></dfn> = <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-hash-token" id="ref-for-typedef-hash-token">&lt;hash-token></a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-class-selector">&lt;class-selector></dfn> = '.' <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token④">&lt;ident-token></a>

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-attribute-selector">&lt;attribute-selector></dfn> = '[' <a class="production" data-link-type="type" href="#typedef-wq-name" id="ref-for-typedef-wq-name①">&lt;wq-name></a> ']' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one⑨">|</a>
                       '[' <a class="production" data-link-type="type" href="#typedef-wq-name" id="ref-for-typedef-wq-name②">&lt;wq-name></a> <a class="production" data-link-type="type" href="#typedef-attr-matcher" id="ref-for-typedef-attr-matcher">&lt;attr-matcher></a> [ <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-string-token" id="ref-for-typedef-string-token②">&lt;string-token></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①⓪">|</a> <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token⑤">&lt;ident-token></a> ] <a class="production" data-link-type="type" href="#typedef-attr-modifier" id="ref-for-typedef-attr-modifier">&lt;attr-modifier></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt⑥">?</a> ']'

<dfn class="dfn-paneled" data-dfn-type="type" data-noexport id="typedef-attr-matcher">&lt;attr-matcher></dfn> = [ '~' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①①">|</a> '|' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①②">|</a> '^' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①③">|</a> '$' <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①④">|</a> '*' ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt⑦">?</a> '='

<dfn class="dfn-paneled" data-dfn-type="type" data-noexport id="typedef-attr-modifier">&lt;attr-modifier></dfn> = i <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①⑤">|</a> s

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-pseudo-class-selector">&lt;pseudo-class-selector></dfn> = ':' <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token⑥">&lt;ident-token></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①⑥">|</a>
                          ':' <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-function-token" id="ref-for-typedef-function-token">&lt;function-token></a> <a class="production" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-any-value" id="ref-for-typedef-any-value">&lt;any-value></a> ')'

<dfn class="dfn-paneled" data-dfn-type="type" data-export id="typedef-pseudo-element-selector">&lt;pseudo-element-selector></dfn> = ':' <a class="production" data-link-type="type" href="#typedef-pseudo-class-selector" id="ref-for-typedef-pseudo-class-selector②">&lt;pseudo-class-selector></a>
</pre>
   <p>In interpreting the above grammar,
	the following rules apply:</p>
   <ul>
    <li id="white-space">
     <a class="self-link" href="#white-space"></a> White space is forbidden: 
     <ul>
      <li data-md>
       <p>Between any of the top-level components of a <a class="production css" data-link-type="type" href="#typedef-compound-selector" id="ref-for-typedef-compound-selector④">&lt;compound-selector></a> (that is, forbidden between the <a class="production css" data-link-type="type" href="#typedef-type-selector" id="ref-for-typedef-type-selector②">&lt;type-selector></a> and <a class="production css" data-link-type="type" href="#typedef-subclass-selector" id="ref-for-typedef-subclass-selector②">&lt;subclass-selector></a>,
or between the <span class="production" id="ref-for-typedef-subclass-selector③">&lt;subclass-selector></span> and <a class="production css" data-link-type="type" href="#typedef-pseudo-element-selector" id="ref-for-typedef-pseudo-element-selector①">&lt;pseudo-element-selector></a>,
etc).</p>
      <li data-md>
       <p>Between <em>any</em> of the components of a <a class="production css" data-link-type="type" href="#typedef-type-selector" id="ref-for-typedef-type-selector③">&lt;type-selector></a> or a <a class="production css" data-link-type="type" href="#typedef-class-selector" id="ref-for-typedef-class-selector①">&lt;class-selector></a>.</p>
      <li data-md>
       <p>Between the ':'s, or between the ':' and <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token" id="ref-for-typedef-ident-token⑦">&lt;ident-token></a> or <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-function-token" id="ref-for-typedef-function-token①">&lt;function-token></a>,
of a <a class="production css" data-link-type="type" href="#typedef-pseudo-element-selector" id="ref-for-typedef-pseudo-element-selector②">&lt;pseudo-element-selector></a> or a <a class="production css" data-link-type="type" href="#typedef-pseudo-class-selector" id="ref-for-typedef-pseudo-class-selector③">&lt;pseudo-class-selector></a>.</p>
      <li data-md>
       <p>Between <em>any</em> of the components of a <a class="production css" data-link-type="type" href="#typedef-wq-name" id="ref-for-typedef-wq-name③">&lt;wq-name></a>.</p>
      <li data-md>
       <p>Between the components of an <a class="production css" data-link-type="type" href="#typedef-attr-matcher" id="ref-for-typedef-attr-matcher①">&lt;attr-matcher></a>.</p>
      <li data-md>
       <p>Between the components of a <a class="production css" data-link-type="type" href="#typedef-combinator" id="ref-for-typedef-combinator②">&lt;combinator></a>.</p>
     </ul>
    <li id="single-colon-pseudos"><a class="self-link" href="#single-colon-pseudos"></a> The four <a href="https://www.w3.org/TR/CSS2/selectors.html#pseudo-element-selectors">Level 2</a> <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②④">pseudo-elements</a> (<a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-before" id="ref-for-selectordef-before③">::before</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-after" id="ref-for-selectordef-after②">::after</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line" id="ref-for-selectordef-first-line⑨">::first-line</a>, and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter" id="ref-for-selectordef-first-letter②">::first-letter</a>)
		may, for legacy reasons,
		be represented using the <a class="production css" data-link-type="type" href="#typedef-pseudo-class-selector" id="ref-for-typedef-pseudo-class-selector④">&lt;pseudo-class-selector></a> grammar,
		with only a single ":" character at their start. 
    <li> In <a class="production css" data-link-type="type" href="#typedef-id-selector" id="ref-for-typedef-id-selector①">&lt;id-selector></a>, the <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#typedef-hash-token" id="ref-for-typedef-hash-token①">&lt;hash-token></a>’s value must be an <a data-link-type="dfn" href="https://drafts.csswg.org/css-syntax-3/#identifier" id="ref-for-identifier③">identifier</a>. 
   </ul>
   <p class="note" role="note"><span>Note:</span> A selector is also subject to a variety of more specific syntactic constraints,
	and adherence to the grammar above is necessary <em>but not sufficient</em> for the selector to be considered valid.
	See <a href="#invalid">§ 3.9 Invalid Selectors and Error Handling</a> for additional rules for parsing selectors.</p>
   <p class="note" role="note"><span>Note:</span> The grammar above states that a combinator is optional
	between two <a class="production css" data-link-type="type" href="#typedef-compound-selector" id="ref-for-typedef-compound-selector⑤">&lt;compound-selector></a>s in a <a class="production css" data-link-type="type" href="#typedef-complex-selector" id="ref-for-typedef-complex-selector③">&lt;complex-selector></a>.
	This is only for grammatical purposes,
	as the <a data-link-type="dfn">CSS Value Definition Syntax</a>’s lax treatment of whitespace
	makes it difficult to indicate that a grammar term can <em>be</em> whitespace.
	"Omitting" a combinator is actually just specifying the <a data-link-type="dfn" href="#descendant-combinator" id="ref-for-descendant-combinator④">descendant combinator</a>.</p>
   <p class="note" role="note"><span>Note:</span> In general,
	a <a class="production css" data-link-type="type" href="#typedef-pseudo-element-selector" id="ref-for-typedef-pseudo-element-selector③">&lt;pseudo-element-selector></a> is only valid
	if placed at the end of the last <a class="production css" data-link-type="type" href="#typedef-compound-selector" id="ref-for-typedef-compound-selector⑥">&lt;compound-selector></a> in a <a class="production css" data-link-type="type" href="#typedef-complex-selector" id="ref-for-typedef-complex-selector④">&lt;complex-selector></a>.
	In some circumstances, however,
	it can be followed by more <span class="production" id="ref-for-typedef-pseudo-element-selector④">&lt;pseudo-element-selector></span>s or <a class="production css" data-link-type="type" href="#typedef-pseudo-class-selector" id="ref-for-typedef-pseudo-class-selector⑤">&lt;pseudo-class-selector></a>s;
	but these are specified on a case-by-case basis.
	(For example, the <a data-link-type="dfn" href="#user-action-pseudo-class" id="ref-for-user-action-pseudo-class">user action pseudo-classes</a> are allowed after any <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②⑤">pseudo-element</a>,
	and the <a data-link-type="dfn" href="https://drafts.csswg.org/css-pseudo-4/#tree-abiding" id="ref-for-tree-abiding">tree-abiding pseudo-elements</a> are allowed after the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-scoping-1/#selectordef-slotted" id="ref-for-selectordef-slotted">::slotted()</a> pseudo-element)</p>
   <h2 class="heading settled" data-level="18" id="api-hooks"><span class="secno">18. </span><span class="content"> API Hooks</span><a class="self-link" href="#api-hooks"></a></h2>
   <p>To aid in the writing of specs that use Selectors concepts,
	this section defines several API hooks that can be invoked by other specifications.</p>
   <p class="issue" id="issue-55d7bd68"><a class="self-link" href="#issue-55d7bd68"></a> Are these still necessary now that we have more rigorous definitions for <a data-link-type="dfn" href="#match" id="ref-for-match⑤">match</a> and <a data-link-type="dfn" href="#invalid-selector" id="ref-for-invalid-selector③">invalid selector</a>?
	Nouns are a lot easier to coordinate across specification than predicates,
	and details like the exact order of elements returned from <code>querySelector</code> seem to make more sense being defined in the DOM specification than in Selectors.</p>
   <h3 class="heading settled algorithm" data-algorithm="Parse A Selector" data-level="18.1" id="parse-selector"><span class="secno">18.1. </span><span class="content"> Parse A Selector</span><a class="self-link" href="#parse-selector"></a></h3>
   <p>This section defines how to <dfn data-dfn-type="dfn" data-export id="parse-a-selector">parse a selector<a class="self-link" href="#parse-a-selector"></a></dfn> from a string <var>source</var>.
	It returns either a complex selector list,
	or failure.</p>
   <ol>
    <li> Let <var>selector</var> be the result of parsing <var>source</var> as a <a class="production css" data-link-type="type" href="#typedef-selector-list" id="ref-for-typedef-selector-list">&lt;selector-list></a>.
			If it does not match the grammar,
			it’s an <a data-link-type="dfn" href="#invalid-selector" id="ref-for-invalid-selector④">invalid selector</a>;
			return failure. 
    <li> If <var>selector</var> is an <a data-link-type="dfn" href="#invalid-selector" id="ref-for-invalid-selector⑤">invalid selector</a> for any other reason
			(such as, for example, containing an undeclared namespace prefix),
			return failure. 
    <li> Otherwise,
			return <var>selector</var>. 
   </ol>
   <h3 class="heading settled algorithm" data-algorithm="Parse A Relative Selector" data-level="18.2" id="parse-relative-selector"><span class="secno">18.2. </span><span class="content"> Parse A Relative Selector</span><a class="self-link" href="#parse-relative-selector"></a></h3>
   <p>This section defines how to <dfn data-dfn-type="dfn" data-export id="parse-a-relative-selector">parse a relative selector<a class="self-link" href="#parse-a-relative-selector"></a></dfn> from a string <var>source</var>,
	against <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element⑨">:scope elements</a> <var>refs</var>.
	It returns either a complex selector list,
	or failure.</p>
   <ol>
    <li> Let <var>selector</var> be the result of parsing <var>source</var> as a <a class="production css" data-link-type="type" href="#typedef-relative-selector-list" id="ref-for-typedef-relative-selector-list">&lt;relative-selector-list></a>.
			If it does not match the grammar,
			return failure. 
    <li> Otherwise,
			if any simple selectors in <var>selector</var> are not recognized by the user agent,
			or <var>selector</var> is otherwise invalid in some way
			(such as, for example, containing an undeclared namespace prefix),
			return failure. 
    <li> Otherwise, <a data-link-type="dfn" href="#absolutize-list" id="ref-for-absolutize-list">absolutize <var>selector</var></a> with <var>refs</var> as the <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element①⓪">:scope elements</a>. 
    <li> Return <var>selector</var>. 
   </ol>
   <h3 class="heading settled algorithm" data-algorithm="Match a Selector Against an Element" data-level="18.3" id="match-against-element"><span class="secno">18.3. </span><span class="content"> Match a Selector Against an Element</span><a class="self-link" href="#match-against-element"></a></h3>
   <p>This section defines how to <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="match-a-selector-against-an-element">match a selector against an element</dfn>.</p>
   <p>APIs using this algorithm must provide a <var>selector</var> and an <var>element</var>.</p>
   <p>Callers may optionally provide:</p>
   <ul>
    <li>
      a set of <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element①①">:scope elements</a>,
			for resolving the <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo⑧">:scope</a> pseudo-class against.
			If not specified,
			the set defaults to being empty. 
     <p class="issue" id="issue-8e6907ff"><a class="self-link" href="#issue-8e6907ff"></a> Should it instead default to the root element,
			to match the definition of <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo⑨">:scope</a>?</p>
     <p>If the selector is a <a data-link-type="dfn" href="#relative-selector" id="ref-for-relative-selector④">relative selector</a>,
			the set of <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element①②">:scope elements</a> must not be empty.</p>
   </ul>
   <p>This algorithm returns either success or failure.</p>
   <p>For each <a data-link-type="dfn" href="#complex" id="ref-for-complex⑨">complex selector</a> in the given <var>selector</var> (which is taken to be a <a data-link-type="dfn" href="#list-of-simple-selectors" id="ref-for-list-of-simple-selectors①">list of complex selectors</a>),
	match the complex selector against <var>element</var>,
	as described in the following paragraph.
	If the matching returns success for any complex selector,
	then the algorithm return success; otherwise it returns failure.</p>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="match-a-complex-selector-against-an-element">match a complex selector against an element</dfn>,
	process it <a data-link-type="dfn" href="#compound" id="ref-for-compound③⑧">compound selector</a> at a time,
	in right-to-left order.
	This process is defined recursively as follows:</p>
   <ul>
    <li>If any simple selectors in the rightmost compound selector
		does not match the element, return failure. 
    <li>Otherwise, if there is only one compound selector in the
		complex selector, return success. 
    <li>Otherwise, consider all possible elements
		that could be related to this element by the rightmost <a data-link-type="dfn" href="#selector-combinator" id="ref-for-selector-combinator⑨">combinator</a>.
		If the operation of matching the selector consisting of this selector
		with the rightmost compound selector and rightmost combinator removed
		against any one of these elements returns success, then return success.
		Otherwise, return failure. 
   </ul>
   <h3 class="heading settled algorithm" data-algorithm="Match a Selector Against a Pseudo-element" data-level="18.4" id="match-against-pseudo-element"><span class="secno">18.4. </span><span class="content"> Match a Selector Against a Pseudo-element</span><a class="self-link" href="#match-against-pseudo-element"></a></h3>
   <p>This section defines how to <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="match-a-selector-against-a-pseudo-element">match a selector against a pseudo-element</dfn>.</p>
   <p>APIs using this algorithm must provide a <var>selector</var> and a <var>pseudo-element</var>.
	They may optionally provide the same things they may optionally provide
	to the algorithm to <a data-link-type="dfn" href="#match-a-selector-against-an-element" id="ref-for-match-a-selector-against-an-element">match a selector against an element</a>.</p>
   <p>This algorithm returns success or failure.</p>
   <p>For each <a data-link-type="dfn" href="#complex" id="ref-for-complex①⓪">complex selector</a> in the given <var>selector</var>, if both:</p>
   <ul>
    <li>the rightmost <a data-link-type="dfn" href="#simple" id="ref-for-simple①③">simple selector</a> in the complex selector
		matches <var>pseudo-element</var>, and 
    <li>the result of running <a data-link-type="dfn" href="#match-a-complex-selector-against-an-element" id="ref-for-match-a-complex-selector-against-an-element">match a complex selector against an element</a> on the remainder of the <a data-link-type="dfn" href="#complex" id="ref-for-complex①①">complex selector</a> (with just the rightmost simple selector
		of its rightmost complex selector removed), <var>pseudo-element</var>’s corresponding element,
		and any optional parameters provided to this algorithm
		returns success, 
   </ul>
    then return success. 
   <p>Otherwise
	(that is, if this doesn’t happen for any of the complex selectors in <var>selector</var>),
	return failure.</p>
   <h3 class="heading settled algorithm" data-algorithm="Match a Selector Against a Tree" data-level="18.5" id="match-against-tree"><span class="secno">18.5. </span><span class="content"> Match a Selector Against a Tree</span><a class="self-link" href="#match-against-tree"></a></h3>
   <p>This section defines how to <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="match-a-selector-against-a-tree">match a selector against a tree</dfn>.</p>
   <p>APIs using this algorithm must provide a selector,
	and one or more <var>root elements</var> indicating the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree" id="ref-for-concept-tree">trees</a> that will be searched by the selector.
	All of the <var>root elements</var> must share the same <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-root" id="ref-for-concept-tree-root">root</a>,
	or else calling this algorithm is invalid.</p>
   <p>They may optionally provide:</p>
   <ul>
    <li>
      A <a data-link-type="dfn" href="#scoping-root" id="ref-for-scoping-root⑤">scoping root</a> indicating the selector is <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector⑥">scoped</a>.
			If not specified,
			the <var>selector</var> defaults to being unscoped. 
     <p class="issue" id="issue-298e030f"><a class="self-link" href="#issue-298e030f"></a> This is now redundant with the <var>root elements</var>.</p>
    <li>
      A set of <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element①③">:scope elements</a>,
			which will match the <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo①⓪">:scope</a> pseudo-class.
			If not specified,
			then if the selector is a <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector⑦">scoped selector</a>,
			the set of <span id="ref-for-scope-element①④">:scope elements</span> default to the <a data-link-type="dfn" href="#scoping-root" id="ref-for-scoping-root⑥">scoping root</a>;
			otherwise,
			it defaults to the <var>root elements</var>. 
     <p class="note" role="note"><span>Note:</span> Note that if the selector is scoped,
			the scoping root is automatically taken as the <a data-link-type="dfn" href="#scope-element" id="ref-for-scope-element①⑤">:scope element</a>,
			so it doesn’t have to be provided explicitly
			unless a different result is desired.</p>
    <li>
      Which <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②⑥">pseudo-elements</a> are allowed to show up in the match list.
			If not specified, this defaults to allowing all pseudo-elements. 
     <p class="issue" id="issue-eaeaf8e2"><a class="self-link" href="#issue-eaeaf8e2"></a> Only the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-before" id="ref-for-selectordef-before④">::before</a> and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-after" id="ref-for-selectordef-after③">::after</a> pseudo-elements are really
			handled in any way remotely like this.</p>
   </ul>
   <p>This algorithm returns a (possibly empty) list of elements.</p>
   <ol>
    <li> Start with a list of <var>candidate elements</var>,
			which are the the <var>root elements</var> and all of their descendant elements,
			sorted in <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order" id="ref-for-concept-shadow-including-tree-order">shadow-including tree order</a>,
			unless otherwise specified. 
    <li> If an optional scoping root was provided,
			then remove from the <var>candidate elements</var> any elements that are not <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-descendant" id="ref-for-concept-tree-descendant">descendants</a> of the <a data-link-type="dfn" href="#scoping-root" id="ref-for-scoping-root⑦">scoping root</a>. 
    <li> Initialize the <var>selector match list</var> to empty. 
    <li>
      For each <var>element</var> in the set of <var>candidate elements</var>: 
     <ol>
      <li> If the result of <a data-link-type="dfn" href="#match-a-selector-against-an-element" id="ref-for-match-a-selector-against-an-element①">match a selector against an element</a> for <var>element</var> and <var>selector</var> is success,
				add <var>element</var> to the <var>selector match list</var>. 
      <li>
        For each possible pseudo-element associated with <var>element</var> that is one of the pseudo-elements allowed to show up in the match list,
				if the result of <a data-link-type="dfn" href="#match-a-selector-against-a-pseudo-element" id="ref-for-match-a-selector-against-a-pseudo-element">match a selector against a pseudo-element</a> for the pseudo-element and <var>selector</var> is success,
				add the pseudo-element to the <var>selector match list</var>. 
       <p class="issue" id="issue-b7f52036"><a class="self-link" href="#issue-b7f52036"></a> The relative position of pseudo-elements
				in <var>selector match list</var> is undefined.
				There’s not yet a context that exposes this information,
				but we need to decide on something eventually,
				before something <em>is</em> exposed.</p>
     </ol>
   </ol>
   <h2 class="heading settled" data-level="19" id="dom-mapping"><span class="secno">19. </span><span class="content"> Appendix A: Guidance on Mapping Source Documents &amp; Data to an Element Tree</span><a class="self-link" href="#dom-mapping"></a></h2>
   <p><em>This section is informative.</em></p>
   <p>The element tree structure described by the DOM is powerful and useful,
	but generic enough to model pretty much any language that describes tree-based data
	(or even graph-based, with a suitable interpretation).</p>
   <p>Some languages, like HTML, already have well-defined procedures
	for producing a DOM object from a resource.
	If a given language does not,
	such a procedure must be defined
	in order for Selectors to apply to documents in that language.</p>
   <p>At minimum,
	the document language must define what maps to the DOM concept of an "element".</p>
   <p>The primary one-to-many relationship between nodes—<wbr>parent/child in tree-based structures,
	element/neighbors in graph-based structures—<wbr>should be reflected as the child nodes of an element.</p>
   <p>Other features of the element should be mapped
	to something that serves a similar purpose to the same feature in DOM:</p>
   <dl>
    <dt>type 
    <dd>
      If the elements in the document language have some notion of "type"
			as a basic distinguisher between different groups of elements,
			it should be reflected as the "type" feature. 
     <p>If this "type" can be separated into a "basic" name
			and a "namespace" that groups names into higher-level groups,
			the latter should be reflected as the "namespace" feature.
			Otherwise, the element shouldn’t have a "namespace" feature,
			and the entire name should be reflected as the "type" feature.</p>
    <dt>id 
    <dd>
      If some aspect of the element functions as a unique identifier across the document,
			it should be mapped to the "id" feature. 
     <p class="note" role="note"><span>Note:</span> While HTML only allows an element to have a single ID,
			this should not be taken as a general restriction.
			The important quality of an ID is that each ID should be associated with a single element;
			a single element can validly have multiple IDs.</p>
    <dt>classes and attributes 
    <dd> Aspects of the element that are useful for identifying the element,
			but are not generally unique to elements within a document,
			should be mapped to the "class" or "attribute" features
			depending on if they’re something equivalent to a "label" (a string by itself)
			or a "property" (a name/value pair) 
    <dt>pseudo-classes and pseudo-elements 
    <dd>
      If any elements match any pseudo-classes or have any pseudo-elements,
			that must be explicitly defined. 
     <p class="issue" id="issue-772ec278"><a class="self-link" href="#issue-772ec278"></a> Some pseudo-classes are *syntactical*,
			like <a class="css" data-link-type="maybe" href="#has-pseudo" id="ref-for-has-pseudo③">:has()</a> and <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①⑤">:is()</a>,
			and thus should always work.
			Need to indicate that somewhere.
			Probably the structural pseudos always work
			whenever the child list is ordered.</p>
   </dl>
   <div class="example" id="example-37a1ab6b">
    <a class="self-link" href="#example-37a1ab6b"></a> For example, <a href="https://github.com/lloyd/JSONSelect">JSONSelect</a> is a library that uses selectors
		to extract information from JSON documents. 
    <ul>
     <li> The "elements" of the JSON document
				are each array, object, boolean, string, number, or null.
				The array and object elements have their contents as children. 
     <li> Each element’s type is its JS type name:
				"array", "object", etc. 
     <li> Children of an object
				have their key as a class. 
     <li> Children of an array match the <a class="css" data-link-type="maybe" href="#first-child-pseudo" id="ref-for-first-child-pseudo②">:first-child</a>, <a class="css" data-link-type="maybe" href="#nth-child-pseudo" id="ref-for-nth-child-pseudo⑤">:nth-child()</a>, etc pseudo-classes. 
     <li> The root object matches <a class="css" data-link-type="maybe" href="#root-pseudo" id="ref-for-root-pseudo③">:root</a>. 
     <li> It additionally defines <span class="css">:val()</span> and <span class="css">:contains()</span> pseudo-classes,
				for matching boolean/number/string elements with a particular value
				or which contain a particular substring. 
    </ul>
    <p>This structure is sufficient to allow powerful, compact querying of JSON documents with selectors.</p>
   </div>
   <h2 class="heading settled" data-level="20" id="compat"><span class="secno">20. </span><span class="content"> Appendix B: Obsolete but Required Parsing Quirks for Web Compat</span><a class="self-link" href="#compat"></a></h2>
   <p><em>This appendix is normative.</em></p>
   <p>Due to legacy Web-compat constraints,
	User Agents expecting to parse Web documents must support the following features:</p>
   <ul>
    <li data-md>
     <p>All <a data-link-type="dfn" href="#pseudo-element" id="ref-for-pseudo-element②⑦">pseudo-elements</a> whose names begin with the string “-webkit-”
(matched <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive④">ASCII case-insensitively</a>)
and that are not functional notations
must be treated as valid at parse time.
(That is, <span class="css">::-webkit-asdf</span> is valid at parse time,
but <span class="css">::-webkit-jkl()</span> is not.)
If they’re not otherwise recognized and supported,
they must be treated as matching nothing, and are <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="unknown--webkit--pseudo-elements">unknown -webkit- pseudo-elements</dfn>.</p>
     <p><a data-link-type="dfn" href="#unknown--webkit--pseudo-elements" id="ref-for-unknown--webkit--pseudo-elements">Unknown -webkit- pseudo-elements</a> must be serialized in ASCII lowercase.</p>
     <details class="note">
      <summary>What’s this quirk about?</summary>
      <p>Selectors have long had a behavior
	where a single unknown/invalid selector
	invalidates the entire selector list
	(rather than just invalidating the one complex selector it finds itself in).
	This is generally considered a legacy mistake by the WG,
	but can’t be fixed at this point,
	as too many stylesheets depend on this behavior,
	intentionally or not.</p>
      <p>One aspect of this is that use of vendor-specific selectors
	invalidates the entire selector in other User Agents
	that don’t recognize them,
	and takes the entire style rule down with it.
	This has been used intentionally in the past—<wbr>in the severely-not-recommended practice of hiding style rules from some browsers
	by making them invalid in every other browser—<wbr>and unintentionally,
	with people styling an element
	and also applying those styles to a vendor-specific pseudo-element
	(such as the various <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/input.html#the-input-element" id="ref-for-the-input-element④">input</a></code>-related pseudos some browsers expose),
	not realizing that this hides the entire rule from other browsers.</p>
      <p>In addition to this more general reasoning,
	WebKit-derived user agents,
	such as Safari or Chrome,
	have an additional quirk related to their vendor-prefixed pseudo-elements,
	where any <span class="css">::-webkit-</span>-prefixed selectors are considered valid at parse time.
	(This is probably a leftover quirk of an early CSS feature,
	since dropped,
	that intentionally treated all possible pseudo-elements as valid at parse time,
	in anticipation of a feature letting authors define their own pseudo-elements.)</p>
      <p>Similar to other legacy quirks,
	such as those documented in <a data-link-type="biblio" href="#biblio-quirks">[QUIRKS]</a>,
	this particular vendor-specific oddity has become common enough
	that other user agents are seeing sites breaking due to them depending on it,
	accidentally or not.
	As such, since the quirk is in practical terms <em>required</em> to render the modern web correctly,
	specifying it and requiring it for all user agents
	ensures that today’s web pages are more likely to be correctly rendered
	in user agents both current and future.</p>
      <p>As usual with quirks, however,
	webpages intentionally relying on this
	will be met with shaming and derision from members of the CSSWG,
	and all right-thinking web developers.</p>
     </details>
   </ul>
   <h2 class="heading settled" data-level="21" id="changes"><span class="secno">21. </span><span class="content"> Changes</span><a class="self-link" href="#changes"></a></h2>
   <h3 class="heading settled" data-level="21.1" id="changes-2018-02"><span class="secno">21.1. </span><span class="content"> Changes since the 2 February 2018 Working Draft</span><a class="self-link" href="#changes-2018-02"></a></h3>
   <p>Significant changes since the <a href="https://www.w3.org/TR/2018/WD-selectors-4-20180202/">2 February 2018 Working Draft</a>:</p>
   <ul>
    <li>Named the zero-specificity selector to <a class="css" data-link-type="maybe" href="#where-pseudo" id="ref-for-where-pseudo④">:where()</a>.
		(<a href="https://github.com/w3c/csswg-drafts/issues/2143">Issue 2143</a>) 
    <li>Renamed <a class="css" data-link-type="maybe" href="#selectordef-matches" id="ref-for-selectordef-matches">:matches()</a> to <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①⑥">:is()</a>.
		(<a href="https://github.com/w3c/csswg-drafts/issues/3258">Issue 3258</a>) 
    <li>Redefined <a class="css" data-link-type="maybe" href="#empty-pseudo" id="ref-for-empty-pseudo②">:empty</a> to ignore white-space–only nodes.
		(<a href="https://github.com/w3c/csswg-drafts/issues/1967">Issue 1967</a>) 
    <li>Redefined <a class="css" data-link-type="maybe" href="#blank-pseudo" id="ref-for-blank-pseudo②">:blank</a> to represent empty user input, rather than empty elements.
		(<a href="https://github.com/w3c/csswg-drafts/issues/1283">Issue 1283</a>) 
    <li>Changed the specificity of <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①⑦">:is()</a>, <a class="css" data-link-type="maybe" href="#has-pseudo" id="ref-for-has-pseudo④">:has()</a>, and <a class="css" data-link-type="maybe" href="#nth-child-pseudo" id="ref-for-nth-child-pseudo⑥">:nth-child()</a> to not depend on which selector argument matched.
		(<a href="https://github.com/w3c/csswg-drafts/issues/1027">Issue 1027</a>) 
    <li>Dropped the <span class="css">:drop()</span> pseudo-classes since HTML dropped the related feature.
		(<a href="https://github.com/w3c/csswg-drafts/issues/2257">Issue 2257</a>) 
    <li>Added the case-sensitive flag <code>s</code> to the attribute selector.
		(<a href="https://github.com/w3c/csswg-drafts/issues/2101">Issue 2101</a>) 
    <li>Added further guidance on <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo①⑦">:focus-visible</a>. 
    <li>Added <a href="#compat">§ 20 Appendix B: Obsolete but Required Parsing Quirks for Web Compat</a> defining <span class="css">::-webkit-</span> pseudo-element parsing quirk.
		(<a href="https://github.com/w3c/csswg-drafts/issues/3051">Issue 3051</a>) 
    <li>Rewrote grammar rules about where white space is allowed for clarity.
		(See <a href="#grammar">§ 17 Grammar</a>.) 
   </ul>
   <h3 class="heading settled" data-level="21.2" id="changes-2013"><span class="secno">21.2. </span><span class="content"> Changes since the 2 May 2013 Working Draft</span><a class="self-link" href="#changes-2013"></a></h3>
   <p>Significant changes since the <a href="https://www.w3.org/TR/2013/WD-selectors4-20130502/">2 May 2013 Working Draft</a> include:</p>
   <ul>
    <li>Added the <a class="css" data-link-type="maybe" href="#target-within-pseudo" id="ref-for-target-within-pseudo③">:target-within</a>, <a class="css" data-link-type="maybe" href="#focus-within-pseudo" id="ref-for-focus-within-pseudo②">:focus-within</a>, <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo①⑧">:focus-visible</a>, <a class="css" data-link-type="maybe" href="#selectordef-playing" id="ref-for-selectordef-playing①">:playing</a>, and <a class="css" data-link-type="maybe" href="#selectordef-paused" id="ref-for-selectordef-paused①">:paused</a> pseudo-classes. 
    <li>Added a zero-specificity <a class="css" data-link-type="maybe" href="#selectordef-matches" id="ref-for-selectordef-matches①">:matches()</a>-type pseudo-class, with name TBD. 
    <li>Replaced subject indicator (<span class="css">!</span>) feature with <a class="css" data-link-type="maybe" href="#has-pseudo" id="ref-for-has-pseudo⑤">:has()</a>. 
    <li>Replaced the <span class="css">:nth-match()</span> and <span class="css">:nth-last-match()</span> selectors
		    with <span class="css">:nth-child(… of selector)</span> and <span class="css">:nth-last-child(… of selector)</span>. 
    <li>Changed the <span class="css">:active-drop-target</span>, <span class="css">:valid-drop-target</span>, <span class="css">:invalid-drop-target</span> with <span class="css">:drop()</span>. 
    <li>Sketched out an empty-or-whitespace-only selector for discussion
			(See <a href="https://github.com/w3c/csswg-drafts/issues/1967">open issue</a>.) 
    <li>Renamed <span class="css">:user-error</span> to <a class="css" data-link-type="maybe" href="#user-invalid-pseudo" id="ref-for-user-invalid-pseudo④">:user-invalid</a>.
		    (See <a href="https://www.w3.org/mid/CADhPm3v+WfeGQfBwwx8QBuiOjn2k38V_DcKW17Cm81VgZb1nbQ@mail.gmail.com">Discussion</a>) 
    <li>Renamed <span class="css">:nth-column()</span>/<span class="css">:nth-last-column()</span> to <a class="css" data-link-type="maybe" href="#nth-col-pseudo" id="ref-for-nth-col-pseudo②">:nth-col()</a>/<a class="css" data-link-type="maybe" href="#nth-last-col-pseudo" id="ref-for-nth-last-col-pseudo②">:nth-last-col()</a> to avoid naming confusion with a potential <span class="css">::column</span> pseudo-class. 
    <li>Changed the non-functional form of the <span class="css">:local-link</span> pseudo-class to account for fragment URLs. 
    <li>Removed the functional form of the <code>:local-link()</code> pseudo-class and reference combinator for lack of interest. 
    <li>Rewrote selectors grammar using the CSS Value Definition Syntax. 
    <li>Split out <a data-link-type="dfn" href="#relative-selector" id="ref-for-relative-selector⑤">relative selectors</a> from <a data-link-type="dfn" href="#scoped-selector" id="ref-for-scoped-selector⑧">scoped selectors</a>,
			as these are different concepts that can be independently invoked. 
    <li>
     Moved definition of <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#anb-production" id="ref-for-anb-production">&lt;An+B></a> microsyntax to CSS Syntax. 
     <p class="issue" id="issue-fb60ae39"><a class="self-link" href="#issue-fb60ae39"></a> Semantic definition should probably move back here.</p>
    <li>
     Added new sections: 
     <ul>
      <li>
       <a href="#data-model">§ 3.2 Data Model</a> 
       <p class="issue" id="issue-4ca3978c"><a class="self-link" href="#issue-4ca3978c"></a> Need to define tree for XML.</p>
      <li>
       <a href="#api-hooks">§ 18 API Hooks</a> 
       <ul>
        <li>Note that earlier versions of this section defined a section on <dfn data-dfn-type="dfn" data-noexport id="evaluating-selectors">evaluating a selector<a class="self-link" href="#evaluating-selectors"></a></dfn>,
						but that section is no longer present.
						Specifications referencing that section should instead reference
						the algorithm to <a data-link-type="dfn" href="#match-a-selector-against-a-tree" id="ref-for-match-a-selector-against-a-tree">match a selector against a tree</a>. 
       </ul>
     </ul>
    <li>Removed restriction on combinators within <a class="css" data-link-type="maybe" href="#selectordef-matches" id="ref-for-selectordef-matches②">:matches()</a> and <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo①⓪">:not()</a>;
			see <a href="https://lists.w3.org/Archives/Public/www-style/2014Jan/0607.html">discussion</a>. 
    <li>Defined <a data-link-type="dfn" href="#specificity" id="ref-for-specificity">specificity</a> of a <a data-link-type="dfn" href="#selector-list" id="ref-for-selector-list①④">selector list</a>. (Why?) 
    <li>Required quotes around <a class="css" data-link-type="maybe" href="#lang-pseudo" id="ref-for-lang-pseudo⑤">:lang()</a> values involving an asterisk;
			only language codes which happen to be CSS identifiers can be used unquoted. 
   </ul>
   <p class="note" role="note"><span>Note:</span> The 1 February 2018 draft included an inadvertent commit of unfinished work;
	2 February 2018 has reverted this commit (and fixed some links because why not).</p>
   <h3 class="heading settled" data-level="21.3" id="changes-2012"><span class="secno">21.3. </span><span class="content"> Changes since the 23 August 2012 Working Draft</span><a class="self-link" href="#changes-2012"></a></h3>
   <p>Significant changes since the <a href="https://www.w3.org/TR/2012/WD-selectors4-20120823/">23 August 2012 Working Draft</a> include:</p>
   <ul>
    <li>Added <a class="css" data-link-type="maybe" href="#placeholder-shown-pseudo" id="ref-for-placeholder-shown-pseudo②">:placeholder-shown</a> pseudo-classes. 
    <li>Released some restrictions on <a class="css" data-link-type="maybe" href="#selectordef-matches" id="ref-for-selectordef-matches③">:matches()</a> and <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo①①">:not()</a>. 
    <li>Defined fast and complete Selectors profiles (now called <a data-link-type="dfn" href="#live-profile" id="ref-for-live-profile④">live</a> and <a data-link-type="dfn" href="#snapshot-profile" id="ref-for-snapshot-profile③">snapshot</a>). 
    <li>Improved definition of <a data-link-type="dfn" href="#specificity" id="ref-for-specificity①">specificity</a> to better handle <a class="css" data-link-type="selector" href="#selectordef-matches" id="ref-for-selectordef-matches④">:matches()</a>. 
    <li>Updated grammar. 
    <li>Cleaned up definition of <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-syntax-3/#anb-production" id="ref-for-anb-production①">&lt;An+B></a> notation. 
    <li>Added definition of <a data-link-type="dfn" href="#relative-selector" id="ref-for-relative-selector⑥">scope-relative</a> selectors, changed <i>scope-constrained</i> to scope-filtered for less confusion with scope-contained. 
    <li>The <span class="css">:local-link()</span> pseudo-class now ignores trailing slashes. 
   </ul>
   <h3 class="heading settled" data-level="21.4" id="changes-2011"><span class="secno">21.4. </span><span class="content"> Changes since the 29 September 2011 Working Draft</span><a class="self-link" href="#changes-2011"></a></h3>
   <p>Significant changes since the <a href="https://www.w3.org/TR/2011/WD-selectors4-20110929/">29 September 2011 Working Draft</a> include:</p>
   <ul>
    <li>Added language variant handling per RFC 4647. 
    <li>Added scoped selectors. 
    <li>Added <span class="css">:user-error</span> (now called <a class="css" data-link-type="maybe" href="#user-invalid-pseudo" id="ref-for-user-invalid-pseudo⑤">:user-invalid</a>). 
    <li>Added <span class="css">:valid-drop-target</span>. 
    <li>Changed <a data-link-type="dfn" href="#column-combinator" id="ref-for-column-combinator①">column combinator</a> from double slash to double pipe. 
   </ul>
   <h3 class="heading settled" data-level="21.5" id="changes-level-3"><span class="secno">21.5. </span><span class="content"> Changes Since Level 3</span><a class="self-link" href="#changes-level-3"></a></h3>
   <p>Additions since <a href="https://www.w3.org/TR/selectors-3/">Level 3</a>:</p>
   <ul>
    <li>Extended <a class="css" data-link-type="maybe" href="#negation-pseudo" id="ref-for-negation-pseudo①②">:not()</a> to accept a selector list. 
    <li>Added <a class="css" data-link-type="maybe" href="#matches-pseudo" id="ref-for-matches-pseudo①⑧">:is()</a> and <a class="css" data-link-type="maybe" href="#where-pseudo" id="ref-for-where-pseudo⑤">:where()</a> and <a class="css" data-link-type="maybe" href="#has-pseudo" id="ref-for-has-pseudo⑥">:has()</a>. 
    <li>Added <a class="css" data-link-type="maybe" href="#scope-pseudo" id="ref-for-scope-pseudo①①">:scope</a>. 
    <li>Added <a class="css" data-link-type="maybe" href="#any-link-pseudo" id="ref-for-any-link-pseudo①">:any-link</a> and <a class="css" data-link-type="maybe" href="#local-link-pseudo" id="ref-for-local-link-pseudo②">:local-link</a>. 
    <li>Added <a href="#time-pseudos">time-dimensional pseudo-classes</a>. 
    <li>Added <a class="css" data-link-type="maybe" href="#target-within-pseudo" id="ref-for-target-within-pseudo④">:target-within</a>, <a class="css" data-link-type="maybe" href="#focus-within-pseudo" id="ref-for-focus-within-pseudo③">:focus-within</a>, and <a class="css" data-link-type="maybe" href="#focus-visible-pseudo" id="ref-for-focus-visible-pseudo①⑨">:focus-visible</a>. 
    <li>Added <a class="css" data-link-type="maybe" href="#dir-pseudo" id="ref-for-dir-pseudo③">:dir()</a>. 
    <li>Expanded <a class="css" data-link-type="maybe" href="#lang-pseudo" id="ref-for-lang-pseudo⑥">:lang()</a> to accept wildcard matching and lists of language codes. 
    <li>Expanded <span class="css">:nth-child()</span> to accept a selector list. 
    <li>Merged in input selectors from <a href="https://www.w3.org/TR/css-ui-3/">CSS Basic User Interface Module Level 3</a> and added back <a class="css" data-link-type="maybe" href="#indetermine-pseudo" id="ref-for-indetermine-pseudo④">:indeterminate</a>. 
    <li>Added <a class="css" data-link-type="maybe" href="#blank-pseudo" id="ref-for-blank-pseudo③">:blank</a> and <a class="css" data-link-type="maybe" href="#user-invalid-pseudo" id="ref-for-user-invalid-pseudo⑥">:user-invalid</a>. 
    <li>Added <a href="#table-pseudos">grid-structural (column) selectors</a>. 
    <li>Added case-insensitive / case-sensitive attribute-value matching flags. 
   </ul>
   <h2 class="heading settled" data-level="22" id="acknowledgements"><span class="secno">22. </span><span class="content"> Acknowledgements</span><a class="self-link" href="#acknowledgements"></a></h2>
   <p>The CSS working group would like to thank everyone who contributed
	to the <a href="https://www.w3.org/TR/css3-selectors">previous Selectors</a> specifications over the years,
	as those specifications formed the basis for this one.
	In particular, the working group would like to extend special thanks
	to the following for their specific contributions to Selectors Level 4:
	L. David Baron,
	Andrew Fedoniouk,
	Daniel Glazman,
	Ian Hickson,
	Grey Hodge,
	Lachlan Hunt,
	Anne van Kesteren,
	Jason Cranford Teague,
	Lea Verou</p>
   <h2 class="heading settled" data-level="23" id="priv-sec"><span class="secno">23. </span><span class="content">Privacy and Security Considerations</span><a class="self-link" href="#priv-sec"></a></h2>
   <p>This specification introduces no new privacy or security considerations,
as selectors do not provide any ability not already possible by walking the DOM manually.</p>
  </main>
  <h2 class="no-ref no-num heading settled" id="conformance"><span class="content"> Conformance</span><a class="self-link" href="#conformance"></a></h2>
  <h3 class="heading settled" id="document-conventions"><span class="content"> Document conventions</span><a class="self-link" href="#document-conventions"></a></h3>
  <p>Conformance requirements are expressed with a combination of
	descriptive assertions and RFC 2119 terminology. The key words “MUST”,
	“MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
	“RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
	document are to be interpreted as described in RFC 2119.
	However, for readability, these words do not appear in all uppercase
	letters in this specification. </p>
  <p>All of the text of this specification is normative except sections
	explicitly marked as non-normative, examples, and notes. <a data-link-type="biblio" href="#biblio-rfc2119">[RFC2119]</a> </p>
  <p>Examples in this specification are introduced with the words “for example”
	or are set apart from the normative text with <code>class="example"</code>,
	like this: </p>
  <div class="example" id="example-ae2b6bc0">
   <a class="self-link" href="#example-ae2b6bc0"></a> 
   <p>This is an example of an informative example. </p>
  </div>
  <p>Informative notes begin with the word “Note” and are set apart from the
	normative text with <code>class="note"</code>, like this: </p>
  <p class="note" role="note">Note, this is an informative note. </p>
  <p>Advisements are normative sections styled to evoke special attention and are
	set apart from other normative text with <code>&lt;strong class="advisement"></code>, like
	this: <strong class="advisement"> UAs MUST provide an accessible alternative. </strong> </p>
  <h3 class="heading settled" id="conform-classes"><span class="content"> Conformance classes</span><a class="self-link" href="#conform-classes"></a></h3>
  <p>Conformance to this specification
	is defined for three conformance classes: </p>
  <dl>
   <dt>style sheet 
   <dd>A <a href="http://www.w3.org/TR/CSS2/conform.html#style-sheet">CSS
			style sheet</a>. 
   <dt>renderer 
   <dd>A <a href="http://www.w3.org/TR/CSS2/conform.html#user-agent">UA</a> that interprets the semantics of a style sheet and renders
			documents that use them. 
   <dt>authoring tool 
   <dd>A <a href="http://www.w3.org/TR/CSS2/conform.html#user-agent">UA</a> that writes a style sheet. 
  </dl>
  <p>A style sheet is conformant to this specification
	if all of its statements that use syntax defined in this module are valid
	according to the generic CSS grammar and the individual grammars of each
	feature defined in this module. </p>
  <p>A renderer is conformant to this specification
	if, in addition to interpreting the style sheet as defined by the
	appropriate specifications, it supports all the features defined
	by this specification by parsing them correctly
	and rendering the document accordingly. However, the inability of a
	UA to correctly render a document due to limitations of the device
	does not make the UA non-conformant. (For example, a UA is not
	required to render color on a monochrome monitor.) </p>
  <p>An authoring tool is conformant to this specification
	if it writes style sheets that are syntactically correct according to the
	generic CSS grammar and the individual grammars of each feature in
	this module, and meet all other conformance requirements of style sheets
	as described in this module. </p>
  <h3 class="heading settled" id="conform-responsible"><span class="content"> Requirements for Responsible Implementation of CSS</span><a class="self-link" href="#conform-responsible"></a></h3>
  <p>The following sections define several conformance requirements
		for implementing CSS responsibly,
		in a way that promotes interoperability in the present and future. </p>
  <h4 class="heading settled" id="conform-partial"><span class="content"> Partial Implementations</span><a class="self-link" href="#conform-partial"></a></h4>
  <p>So that authors can exploit the forward-compatible parsing rules to assign fallback values, <strong>CSS renderers <em>must</em> treat as invalid
		(and <a href="http://www.w3.org/TR/CSS2/conform.html#ignore">ignore as appropriate</a>)
		any at-rules, properties, property values, keywords, and other syntactic constructs
		for which they have no usable level of support</strong>.
		In particular, user agents <em>must not</em> selectively ignore
		unsupported property values and honor supported values in a single multi-value property declaration:
		if any value is considered invalid (as unsupported values must be),
		CSS requires that the entire declaration be ignored. </p>
  <h4 class="heading settled" id="conform-future-proofing"><span class="content"> Implementations of Unstable and Proprietary Features</span><a class="self-link" href="#conform-future-proofing"></a></h4>
  <p>To avoid clashes with future stable CSS features,
		the CSSWG recommends <a href="http://www.w3.org/TR/CSS/#future-proofing">following best practices</a> for the implementation of <a href="http://www.w3.org/TR/CSS/#unstable">unstable</a> features and <a href="http://www.w3.org/TR/CSS/#proprietary-extension">proprietary extensions</a> to CSS. </p>
  <h4 class="heading settled" id="conform-testing"><span class="content"> Implementations of CR-level Features</span><a class="self-link" href="#conform-testing"></a></h4>
  <p>Once a specification reaches the Candidate Recommendation stage,
		implementers should release an <a data-link-type="dfn" href="http://www.w3.org/TR/CSS/#vendor-prefix">unprefixed</a> implementation
		of any CR-level feature they can demonstrate
		to be correctly implemented according to spec,
		and should avoid exposing a prefixed variant of that feature. </p>
  <p>To establish and maintain the interoperability of CSS across
		implementations, the CSS Working Group requests that non-experimental
		CSS renderers submit an implementation report (and, if necessary, the
		testcases used for that implementation report) to the W3C before
		releasing an unprefixed implementation of any CSS features. Testcases
		submitted to W3C are subject to review and correction by the CSS
		Working Group. </p>
  <p>
   Further information on submitting testcases and implementation reports
		can be found from on the CSS Working Group’s website at <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
		Questions should be directed to the <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a> mailing list. 
<script src="https://www.w3.org/scripts/TR/2016/fixup.js"></script>
  </p>
  <h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2>
  <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3>
  <ul class="index">
   <li><a href="#selectordef-column">||</a><span>, in §15.1</span>
   <li><a href="#selectordef-adjacent">+</a><span>, in §14.3</span>
   <li><a href="#selectordef-child">></a><span>, in §14.2</span>
   <li><a href="#selectordef-sibling">~</a><span>, in §14.4</span>
   <li><a href="#absolutize">absolutize a relative selector</a><span>, in §3.4.1</span>
   <li><a href="#absolutize-list">absolutize a relative selector list</a><span>, in §3.4.1</span>
   <li><a href="#active-pseudo">:active</a><span>, in §9.2</span>
   <li><a href="#any-link-pseudo">:any-link</a><span>, in §8.1</span>
   <li><a href="#typedef-attribute-selector">&lt;attribute-selector></a><span>, in §17</span>
   <li><a href="#attribute-selector">attribute selector</a><span>, in §6</span>
   <li><a href="#typedef-attr-matcher">&lt;attr-matcher></a><span>, in §17</span>
   <li><a href="#typedef-attr-modifier">&lt;attr-modifier></a><span>, in §17</span>
   <li><a href="#blank-pseudo">:blank</a><span>, in §12.3.1</span>
   <li><a href="#checked-pseudo">:checked</a><span>, in §12.2.1</span>
   <li><a href="#child-combinator">child combinator</a><span>, in §14.2</span>
   <li><a href="#class-selector">class selector</a><span>, in §6.6</span>
   <li><a href="#typedef-class-selector">&lt;class-selector></a><span>, in §17</span>
   <li><a href="#column-combinator">column combinator</a><span>, in §15.1</span>
   <li><a href="#selector-combinator">combinator</a><span>, in §3.1</span>
   <li><a href="#typedef-combinator">&lt;combinator></a><span>, in §17</span>
   <li><a href="#typedef-complex-selector">&lt;complex-selector></a><span>, in §17</span>
   <li><a href="#complex">complex selector</a><span>, in §3.1</span>
   <li><a href="#typedef-complex-selector-list">&lt;complex-selector-list></a><span>, in §17</span>
   <li><a href="#compound">compound selector</a><span>, in §3.1</span>
   <li><a href="#typedef-compound-selector">&lt;compound-selector></a><span>, in §17</span>
   <li><a href="#typedef-compound-selector-list">&lt;compound-selector-list></a><span>, in §17</span>
   <li><a href="#selectordef-current">:current()</a><span>, in §10.1</span>
   <li><a href="#current-pseudo">:current</a><span>, in §10.1</span>
   <li><a href="#nsdecl">declared</a><span>, in §3.8</span>
   <li><a href="#default-pseudo">:default</a><span>, in §12.1.4</span>
   <li><a href="#descendant-combinator">descendant combinator</a><span>, in §14.1</span>
   <li><a href="#dir-pseudo">:dir()</a><span>, in §7.1</span>
   <li><a href="#disabled-pseudo">:disabled</a><span>, in §12.1.1</span>
   <li><a href="#document-language">document language</a><span>, in §3.2</span>
   <li><a href="#empty-pseudo">:empty</a><span>, in §13.2</span>
   <li><a href="#enabled-pseudo">:enabled</a><span>, in §12.1.1</span>
   <li><a href="#evaluating-selectors">evaluating a selector</a><span>, in §21.2</span>
   <li><a href="#featureless">featureless</a><span>, in §3.2</span>
   <li><a href="#first-child-pseudo">:first-child</a><span>, in §13.3.3</span>
   <li><a href="#first-of-type-pseudo">:first-of-type</a><span>, in §13.4.3</span>
   <li><a href="#focus-pseudo">:focus</a><span>, in §9.3</span>
   <li><a href="#focus-visible-pseudo">:focus-visible</a><span>, in §9.4</span>
   <li><a href="#focus-within-pseudo">:focus-within</a><span>, in §9.5</span>
   <li><a href="#functional-pseudo-class">functional pseudo-class</a><span>, in §3.5</span>
   <li><a href="#future-pseudo">:future</a><span>, in §10.3</span>
   <li><a href="#has-pseudo">:has()</a><span>, in §4.5</span>
   <li><a href="#host-language">host language</a><span>, in §3.2</span>
   <li><a href="#hover-pseudo">:hover</a><span>, in §9.1</span>
   <li><a href="#typedef-id-selector">&lt;id-selector></a><span>, in §17</span>
   <li><a href="#id-selector">ID selector</a><span>, in §6.7</span>
   <li><a href="#indetermine-pseudo">:indeterminate</a><span>, in §12.2.2</span>
   <li><a href="#in-range-pseudo">:in-range</a><span>, in §12.3.3</span>
   <li><a href="#invalid-pseudo">:invalid</a><span>, in §12.3.2</span>
   <li><a href="#invalid-selector">invalid</a><span>, in §3.9</span>
   <li><a href="#invalid-selector">invalid selector</a><span>, in §3.9</span>
   <li><a href="#matches-pseudo">:is()</a><span>, in §4.2</span>
   <li><a href="#lang-pseudo">:lang()</a><span>, in §7.2</span>
   <li><a href="#language-range">language range</a><span>, in §7.2</span>
   <li><a href="#last-child-pseudo">:last-child</a><span>, in §13.3.4</span>
   <li><a href="#last-of-type-pseudo">:last-of-type</a><span>, in §13.4.4</span>
   <li><a href="#link-pseudo">:link</a><span>, in §8.2</span>
   <li><a href="#list-of-simple-selectors">list of complex selectors</a><span>, in §3.1</span>
   <li><a href="#list-of-simple-selectors">list of compound selectors</a><span>, in §3.1</span>
   <li><a href="#selector-list">list of selectors</a><span>, in §3.1</span>
   <li><a href="#list-of-simple-selectors">list of simple selectors</a><span>, in §3.1</span>
   <li><a href="#live-profile">live</a><span>, in §2.1</span>
   <li><a href="#live-profile">live profile</a><span>, in §2.1</span>
   <li><a href="#local-link-pseudo">:local-link</a><span>, in §8.3</span>
   <li><a href="#match">match</a><span>, in §3.1</span>
   <li><a href="#match-a-complex-selector-against-an-element">match a complex selector against an element</a><span>, in §18.3</span>
   <li><a href="#match-a-selector-against-an-element">match a selector against an element</a><span>, in §18.3</span>
   <li><a href="#match-a-selector-against-a-pseudo-element">match a selector against a pseudo-element</a><span>, in §18.4</span>
   <li><a href="#match-a-selector-against-a-tree">match a selector against a tree</a><span>, in §18.5</span>
   <li><a href="#selectordef-matches">:matches()</a><span>, in §4.2</span>
   <li><a href="#next-sibling-combinator">next-sibling combinator</a><span>, in §14.3</span>
   <li><a href="#negation-pseudo">:not()</a><span>, in §4.3</span>
   <li><a href="#typedef-ns-prefix">&lt;ns-prefix></a><span>, in §17</span>
   <li><a href="#nth-child-pseudo">:nth-child()</a><span>, in §13.3.1</span>
   <li><a href="#nth-col-pseudo">:nth-col()</a><span>, in §15.2</span>
   <li><a href="#nth-last-child-pseudo">:nth-last-child()</a><span>, in §13.3.2</span>
   <li><a href="#nth-last-col-pseudo">:nth-last-col()</a><span>, in §15.3</span>
   <li><a href="#nth-last-of-type-pseudo">:nth-last-of-type()</a><span>, in §13.4.2</span>
   <li><a href="#nth-of-type-pseudo">:nth-of-type()</a><span>, in §13.4.1</span>
   <li><a href="#only-child-pseudo">:only-child</a><span>, in §13.3.5</span>
   <li><a href="#only-of-type-pseudo">:only-of-type</a><span>, in §13.4.5</span>
   <li><a href="#optional-pseudo">:optional</a><span>, in §12.3.4</span>
   <li><a href="#originating-element">originating element</a><span>, in §3.6.2</span>
   <li><a href="#out-of-range-pseudo">:out-of-range</a><span>, in §12.3.3</span>
   <li><a href="#parse-a-relative-selector">parse a relative selector</a><span>, in §18.2</span>
   <li><a href="#parse-a-selector">parse a selector</a><span>, in §18.1</span>
   <li><a href="#past-pseudo">:past</a><span>, in §10.2</span>
   <li><a href="#selectordef-paused">:paused</a><span>, in §11.1</span>
   <li><a href="#placeholder-shown-pseudo">:placeholder-shown</a><span>, in §12.1.3</span>
   <li><a href="#selectordef-playing">:playing</a><span>, in §11.1</span>
   <li><a href="#pseudo-class">pseudo-class</a><span>, in §3.5</span>
   <li><a href="#typedef-pseudo-class-selector">&lt;pseudo-class-selector></a><span>, in §17</span>
   <li><a href="#pseudo-element">pseudo-element</a><span>, in §3.6</span>
   <li><a href="#typedef-pseudo-element-selector">&lt;pseudo-element-selector></a><span>, in §17</span>
   <li><a href="#read-only-pseudo">:read-only</a><span>, in §12.1.2</span>
   <li><a href="#read-write-pseudo">:read-write</a><span>, in §12.1.2</span>
   <li><a href="#relative-selector">relative</a><span>, in §3.4</span>
   <li><a href="#relative-selector">relative selector</a><span>, in §3.4</span>
   <li><a href="#typedef-relative-selector">&lt;relative-selector></a><span>, in §17</span>
   <li><a href="#typedef-relative-selector-list">&lt;relative-selector-list></a><span>, in §17</span>
   <li><a href="#required-pseudo">:required</a><span>, in §12.3.4</span>
   <li><a href="#root-pseudo">:root</a><span>, in §13.1</span>
   <li><a href="#scope-pseudo">:scope</a><span>, in §8.6</span>
   <li><a href="#scoped-selector">scope</a><span>, in §3.3</span>
   <li><a href="#scoped-selector">scoped selector</a><span>, in §3.3</span>
   <li><a href="#scope-element">:scope element</a><span>, in §8.6</span>
   <li><a href="#relative-selector">scope-relative</a><span>, in §3.4</span>
   <li><a href="#scoping-element">scoping element</a><span>, in §3.3</span>
   <li><a href="#scoping-root">scoping root</a><span>, in §3.3</span>
   <li><a href="#selector">selector</a><span>, in §3.1</span>
   <li><a href="#selector-list">selector list</a><span>, in §3.1</span>
   <li><a href="#typedef-selector-list">&lt;selector-list></a><span>, in §17</span>
   <li><a href="#simple">simple selector</a><span>, in §3.1</span>
   <li><a href="#typedef-simple-selector">&lt;simple-selector></a><span>, in §17</span>
   <li><a href="#typedef-simple-selector-list">&lt;simple-selector-list></a><span>, in §17</span>
   <li><a href="#snapshot-profile">snapshot</a><span>, in §2.1</span>
   <li><a href="#snapshot-profile">snapshot profile</a><span>, in §2.1</span>
   <li><a href="#specificity">specificity</a><span>, in §16</span>
   <li><a href="#structural-pseudo-classes">structural pseudo-classes</a><span>, in §13</span>
   <li><a href="#typedef-subclass-selector">&lt;subclass-selector></a><span>, in §17</span>
   <li><a href="#selector-subject">subject</a><span>, in §3.1</span>
   <li><a href="#selector-subject">subject of a selector</a><span>, in §3.1</span>
   <li><a href="#subsequent-sibling-combinator">subsequent-sibling combinator</a><span>, in §14.4</span>
   <li><a href="#target-pseudo">:target</a><span>, in §8.4</span>
   <li><a href="#target-within-pseudo">:target-within</a><span>, in §8.5</span>
   <li><a href="#typedef-type-selector">&lt;type-selector></a><span>, in §17</span>
   <li><a href="#type-selector">type selector</a><span>, in §5.1</span>
   <li><a href="#universal-selector">universal selector</a><span>, in §5.2</span>
   <li><a href="#unknown--webkit--pseudo-elements">unknown -webkit- pseudo-elements</a><span>, in §20</span>
   <li><a href="#user-action-pseudo-class">user action pseudo-class</a><span>, in §9</span>
   <li><a href="#user-invalid-pseudo">:user-invalid</a><span>, in §12.3.5</span>
   <li><a href="#valid-pseudo">:valid</a><span>, in §12.3.2</span>
   <li><a href="#virtual-scoping-root">virtual scoping root</a><span>, in §3.3</span>
   <li><a href="#visited-pseudo">:visited</a><span>, in §8.2</span>
   <li><a href="#where-pseudo">:where()</a><span>, in §4.4</span>
   <li><a href="#whitespace">White space</a><span>, in §3.7</span>
   <li><a href="#typedef-wq-name">&lt;wq-name></a><span>, in §17</span>
  </ul>
  <aside class="dfn-panel" data-for="term-for-box tree">
   <a href="https://drafts.csswg.org/css-display-3/#box tree">https://drafts.csswg.org/css-display-3/#box tree</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-box%20tree">3.6.4. 
Internal Structure</a> <a href="#ref-for-box%20tree①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-propdef-display">
   <a href="https://drafts.csswg.org/css-display-3/#propdef-display">https://drafts.csswg.org/css-display-3/#propdef-display</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-propdef-display">12.1.1. 
The :enabled and :disabled Pseudo-classes</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-after">
   <a href="https://drafts.csswg.org/css-pseudo-4/#selectordef-after">https://drafts.csswg.org/css-pseudo-4/#selectordef-after</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-after">3.6. Pseudo-elements</a>
    <li><a href="#ref-for-selectordef-after①">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-selectordef-after②">17. 
Grammar</a>
    <li><a href="#ref-for-selectordef-after③">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-before">
   <a href="https://drafts.csswg.org/css-pseudo-4/#selectordef-before">https://drafts.csswg.org/css-pseudo-4/#selectordef-before</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-before">3.6. Pseudo-elements</a>
    <li><a href="#ref-for-selectordef-before①">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-selectordef-before②">3.6.2. 
Binding to the Document Tree</a>
    <li><a href="#ref-for-selectordef-before③">17. 
Grammar</a>
    <li><a href="#ref-for-selectordef-before④">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-first-letter">
   <a href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter">https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-first-letter">3.6. Pseudo-elements</a>
    <li><a href="#ref-for-selectordef-first-letter①">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-selectordef-first-letter②">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-first-line">
   <a href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line">https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-first-line">3.2. 
Data Model</a> <a href="#ref-for-selectordef-first-line①">(2)</a>
    <li><a href="#ref-for-selectordef-first-line②">3.6. Pseudo-elements</a> <a href="#ref-for-selectordef-first-line③">(2)</a>
    <li><a href="#ref-for-selectordef-first-line④">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-selectordef-first-line⑤">3.6.2. 
Binding to the Document Tree</a> <a href="#ref-for-selectordef-first-line⑥">(2)</a>
    <li><a href="#ref-for-selectordef-first-line⑦">3.6.3. 
Pseudo-classing Pseudo-elements</a> <a href="#ref-for-selectordef-first-line⑧">(2)</a>
    <li><a href="#ref-for-selectordef-first-line⑨">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-tree-abiding">
   <a href="https://drafts.csswg.org/css-pseudo-4/#tree-abiding">https://drafts.csswg.org/css-pseudo-4/#tree-abiding</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-tree-abiding">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-content">
   <a href="https://www.w3.org/TR/css-scoping-1/#selectordef-content">https://www.w3.org/TR/css-scoping-1/#selectordef-content</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-content">3.6.4. 
Internal Structure</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-shadow">
   <a href="https://www.w3.org/TR/css-scoping-1/#selectordef-shadow">https://www.w3.org/TR/css-scoping-1/#selectordef-shadow</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-shadow">3.6.4. 
Internal Structure</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-slotted">
   <a href="https://drafts.csswg.org/css-scoping-1/#selectordef-slotted">https://drafts.csswg.org/css-scoping-1/#selectordef-slotted</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-slotted">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-host">
   <a href="https://drafts.csswg.org/css-scoping-1/#selectordef-host">https://drafts.csswg.org/css-scoping-1/#selectordef-host</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-host">3.2. 
Data Model</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-selectordef-host-context">
   <a href="https://drafts.csswg.org/css-scoping-1/#selectordef-host-context">https://drafts.csswg.org/css-scoping-1/#selectordef-host-context</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-host-context">3.2. 
Data Model</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-flat-tree">
   <a href="https://drafts.csswg.org/css-scoping-1/#flat-tree">https://drafts.csswg.org/css-scoping-1/#flat-tree</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-flat-tree">8.5. 
The Target Container Pseudo-class: :target-within</a>
    <li><a href="#ref-for-flat-tree①">9.1. 
The Pointer Hover Pseudo-class: :hover</a>
    <li><a href="#ref-for-flat-tree②">9.2. 
The Activation Pseudo-class: :active</a>
    <li><a href="#ref-for-flat-tree③">9.5. 
The Focus Container Pseudo-class: :focus-within</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-content-language">
   <a href="https://drafts.csswg.org/css-text-3/#content-language">https://drafts.csswg.org/css-text-3/#content-language</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-content-language">7.2. 
The Language Pseudo-class: :lang()</a> <a href="#ref-for-content-language①">(2)</a> <a href="#ref-for-content-language②">(3)</a> <a href="#ref-for-content-language③">(4)</a> <a href="#ref-for-content-language④">(5)</a> <a href="#ref-for-content-language⑤">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-white-space">
   <a href="https://drafts.csswg.org/css-text-3/#white-space">https://drafts.csswg.org/css-text-3/#white-space</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-white-space">13.2. 
:empty pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-string-value">
   <a href="https://drafts.csswg.org/css-values-3/#string-value">https://drafts.csswg.org/css-values-3/#string-value</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-string-value">7.2. 
The Language Pseudo-class: :lang()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-mult-req">
   <a href="https://drafts.csswg.org/css-values-4/#mult-req">https://drafts.csswg.org/css-values-4/#mult-req</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-mult-req">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-mult-comma">
   <a href="https://drafts.csswg.org/css-values-4/#mult-comma">https://drafts.csswg.org/css-values-4/#mult-comma</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-mult-comma">17. 
Grammar</a> <a href="#ref-for-mult-comma①">(2)</a> <a href="#ref-for-mult-comma②">(3)</a> <a href="#ref-for-mult-comma③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-mult-zero-plus">
   <a href="https://drafts.csswg.org/css-values-4/#mult-zero-plus">https://drafts.csswg.org/css-values-4/#mult-zero-plus</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-mult-zero-plus">17. 
Grammar</a> <a href="#ref-for-mult-zero-plus①">(2)</a> <a href="#ref-for-mult-zero-plus②">(3)</a> <a href="#ref-for-mult-zero-plus③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-typedef-ident">
   <a href="https://drafts.csswg.org/css-values-4/#typedef-ident">https://drafts.csswg.org/css-values-4/#typedef-ident</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-ident">7.2. 
The Language Pseudo-class: :lang()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-mult-opt">
   <a href="https://drafts.csswg.org/css-values-4/#mult-opt">https://drafts.csswg.org/css-values-4/#mult-opt</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-mult-opt">17. 
Grammar</a> <a href="#ref-for-mult-opt①">(2)</a> <a href="#ref-for-mult-opt②">(3)</a> <a href="#ref-for-mult-opt③">(4)</a> <a href="#ref-for-mult-opt④">(5)</a> <a href="#ref-for-mult-opt⑤">(6)</a> <a href="#ref-for-mult-opt⑥">(7)</a> <a href="#ref-for-mult-opt⑦">(8)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-comb-one">
   <a href="https://drafts.csswg.org/css-values-4/#comb-one">https://drafts.csswg.org/css-values-4/#comb-one</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-comb-one">17. 
Grammar</a> <a href="#ref-for-comb-one①">(2)</a> <a href="#ref-for-comb-one②">(3)</a> <a href="#ref-for-comb-one③">(4)</a> <a href="#ref-for-comb-one④">(5)</a> <a href="#ref-for-comb-one⑤">(6)</a> <a href="#ref-for-comb-one⑥">(7)</a> <a href="#ref-for-comb-one⑦">(8)</a> <a href="#ref-for-comb-one⑧">(9)</a> <a href="#ref-for-comb-one⑨">(10)</a> <a href="#ref-for-comb-one①⓪">(11)</a> <a href="#ref-for-comb-one①①">(12)</a> <a href="#ref-for-comb-one①②">(13)</a> <a href="#ref-for-comb-one①③">(14)</a> <a href="#ref-for-comb-one①④">(15)</a> <a href="#ref-for-comb-one①⑤">(16)</a> <a href="#ref-for-comb-one①⑥">(17)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-propdef-direction">
   <a href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">https://drafts.csswg.org/css-writing-modes-3/#propdef-direction</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-propdef-direction">7.1. 
The Directionality Pseudo-class: :dir()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-propdef-visibility">
   <a href="https://drafts.csswg.org/css2/visufx.html#propdef-visibility">https://drafts.csswg.org/css2/visufx.html#propdef-visibility</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-propdef-visibility">12.1.1. 
The :enabled and :disabled Pseudo-classes</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-css-qualified-name">
   <a href="https://drafts.csswg.org/css-namespaces-3/#css-qualified-name">https://drafts.csswg.org/css-namespaces-3/#css-qualified-name</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-css-qualified-name">5.1. 
Type (tag name) selector</a>
    <li><a href="#ref-for-css-qualified-name①">5.2. 
Universal selector </a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-default-namespace">
   <a href="https://drafts.csswg.org/css-namespaces-3/#default-namespace">https://drafts.csswg.org/css-namespaces-3/#default-namespace</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-default-namespace">5.3. 
Namespaces in Elemental Selectors</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-anb-production">
   <a href="https://drafts.csswg.org/css-syntax-3/#anb-production">https://drafts.csswg.org/css-syntax-3/#anb-production</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-anb-production">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-anb-production①">21.3. 
Changes since the 23 August 2012 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-typedef-any-value">
   <a href="https://drafts.csswg.org/css-syntax-3/#typedef-any-value">https://drafts.csswg.org/css-syntax-3/#typedef-any-value</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-any-value">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-typedef-function-token">
   <a href="https://drafts.csswg.org/css-syntax-3/#typedef-function-token">https://drafts.csswg.org/css-syntax-3/#typedef-function-token</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-function-token">17. 
Grammar</a> <a href="#ref-for-typedef-function-token①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-typedef-hash-token">
   <a href="https://drafts.csswg.org/css-syntax-3/#typedef-hash-token">https://drafts.csswg.org/css-syntax-3/#typedef-hash-token</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-hash-token">17. 
Grammar</a> <a href="#ref-for-typedef-hash-token①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-typedef-ident-token">
   <a href="https://drafts.csswg.org/css-syntax-3/#typedef-ident-token">https://drafts.csswg.org/css-syntax-3/#typedef-ident-token</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-ident-token">6.1. 
Attribute presence and value selectors</a>
    <li><a href="#ref-for-typedef-ident-token①">6.2. 
Substring matching attribute selectors</a>
    <li><a href="#ref-for-typedef-ident-token②">17. 
Grammar</a> <a href="#ref-for-typedef-ident-token③">(2)</a> <a href="#ref-for-typedef-ident-token④">(3)</a> <a href="#ref-for-typedef-ident-token⑤">(4)</a> <a href="#ref-for-typedef-ident-token⑥">(5)</a> <a href="#ref-for-typedef-ident-token⑦">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-typedef-string-token">
   <a href="https://drafts.csswg.org/css-syntax-3/#typedef-string-token">https://drafts.csswg.org/css-syntax-3/#typedef-string-token</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-string-token">6.1. 
Attribute presence and value selectors</a>
    <li><a href="#ref-for-typedef-string-token①">6.2. 
Substring matching attribute selectors</a>
    <li><a href="#ref-for-typedef-string-token②">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-identifier">
   <a href="https://drafts.csswg.org/css-syntax-3/#identifier">https://drafts.csswg.org/css-syntax-3/#identifier</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-identifier">3.5. 
Pseudo-classes</a>
    <li><a href="#ref-for-identifier①">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-identifier②">5.1. 
Type (tag name) selector</a>
    <li><a href="#ref-for-identifier③">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-css-parse-something-according-to-a-css-grammar">
   <a href="https://drafts.csswg.org/css-syntax-3/#css-parse-something-according-to-a-css-grammar">https://drafts.csswg.org/css-syntax-3/#css-parse-something-according-to-a-css-grammar</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-css-parse-something-according-to-a-css-grammar">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-document">
   <a href="https://dom.spec.whatwg.org/#document">https://dom.spec.whatwg.org/#document</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-document">13.1. 
:root pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-documentfragment">
   <a href="https://dom.spec.whatwg.org/#documentfragment">https://dom.spec.whatwg.org/#documentfragment</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-documentfragment">3.3. 
Scoped Selectors</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-tree-descendant">
   <a href="https://dom.spec.whatwg.org/#concept-tree-descendant">https://dom.spec.whatwg.org/#concept-tree-descendant</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-tree-descendant">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-tree-inclusive-sibling">
   <a href="https://dom.spec.whatwg.org/#concept-tree-inclusive-sibling">https://dom.spec.whatwg.org/#concept-tree-inclusive-sibling</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-tree-inclusive-sibling">13.3. 
Child-indexed Pseudo-classes</a>
    <li><a href="#ref-for-concept-tree-inclusive-sibling①">13.3.1. 
:nth-child() pseudo-class</a>
    <li><a href="#ref-for-concept-tree-inclusive-sibling②">13.3.2. 
:nth-last-child() pseudo-class</a>
    <li><a href="#ref-for-concept-tree-inclusive-sibling③">13.3.3. 
:first-child pseudo-class</a>
    <li><a href="#ref-for-concept-tree-inclusive-sibling④">13.3.4. 
:last-child pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-document-quirks">
   <a href="https://dom.spec.whatwg.org/#concept-document-quirks">https://dom.spec.whatwg.org/#concept-document-quirks</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-document-quirks">6.6. 
Class selectors</a>
    <li><a href="#ref-for-concept-document-quirks①">6.7. 
ID selectors</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-tree-root">
   <a href="https://dom.spec.whatwg.org/#concept-tree-root">https://dom.spec.whatwg.org/#concept-tree-root</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-tree-root">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-element-shadow-host">
   <a href="https://dom.spec.whatwg.org/#element-shadow-host">https://dom.spec.whatwg.org/#element-shadow-host</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-element-shadow-host">3.2. 
Data Model</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-shadow-tree">
   <a href="https://dom.spec.whatwg.org/#concept-shadow-tree">https://dom.spec.whatwg.org/#concept-shadow-tree</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-shadow-tree">3.2. 
Data Model</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-shadow-including-tree-order">
   <a href="https://dom.spec.whatwg.org/#concept-shadow-including-tree-order">https://dom.spec.whatwg.org/#concept-shadow-including-tree-order</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-shadow-including-tree-order">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-tree">
   <a href="https://dom.spec.whatwg.org/#concept-tree">https://dom.spec.whatwg.org/#concept-tree</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-tree">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-area-element">
   <a href="https://html.spec.whatwg.org/multipage/image-maps.html#the-area-element">https://html.spec.whatwg.org/multipage/image-maps.html#the-area-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-area-element">8.1. 
The Hyperlink Pseudo-class: :any-link</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-button-element">
   <a href="https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element">https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-button-element">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-div-element">
   <a href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-div-element">https://html.spec.whatwg.org/multipage/grouping-content.html#the-div-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-div-element">6.6. 
Class selectors</a>
    <li><a href="#ref-for-the-div-element①">13.3.3. 
:first-child pseudo-class</a>
    <li><a href="#ref-for-the-div-element②">14.1. 
Descendant combinator ( )</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-em-element">
   <a href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-em-element">https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-em-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-em-element">14.1. 
Descendant combinator ( )</a> <a href="#ref-for-the-em-element①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-html-element">
   <a href="https://html.spec.whatwg.org/multipage/semantics.html#the-html-element">https://html.spec.whatwg.org/multipage/semantics.html#the-html-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-html-element">13.1. 
:root pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-img-element">
   <a href="https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element">https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-img-element">13.4.1. 
:nth-of-type() pseudo-class</a>
    <li><a href="#ref-for-the-img-element①">13.4.2. 
:nth-last-of-type() pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-input-element">
   <a href="https://html.spec.whatwg.org/multipage/input.html#the-input-element">https://html.spec.whatwg.org/multipage/input.html#the-input-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-input-element">9.4. 
The Focus-Indicated Pseudo-class: :focus-visible</a>
    <li><a href="#ref-for-the-input-element①">12. 
The Input Pseudo-classes</a>
    <li><a href="#ref-for-the-input-element②">12.1.3. 
The Placeholder-shown Pseudo-class: :placeholder-shown</a>
    <li><a href="#ref-for-the-input-element③">12.3.1. 
The Empty-Value Pseudo-class: :blank</a>
    <li><a href="#ref-for-the-input-element④">20. 
Appendix B: Obsolete but Required Parsing Quirks for Web Compat</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-label-element">
   <a href="https://html.spec.whatwg.org/multipage/forms.html#the-label-element">https://html.spec.whatwg.org/multipage/forms.html#the-label-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-label-element">9.1. 
The Pointer Hover Pseudo-class: :hover</a>
    <li><a href="#ref-for-the-label-element①">9.3. 
The Input Focus Pseudo-class: :focus</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-li-element">
   <a href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-li-element">https://html.spec.whatwg.org/multipage/grouping-content.html#the-li-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-li-element">14.2. 
Child combinator (>)</a> <a href="#ref-for-the-li-element①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-meta">
   <a href="https://html.spec.whatwg.org/multipage/semantics.html#meta">https://html.spec.whatwg.org/multipage/semantics.html#meta</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-meta">7.2. 
The Language Pseudo-class: :lang()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-object-element">
   <a href="https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element">https://html.spec.whatwg.org/multipage/iframe-embed-object.html#the-object-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-object-element">6.2. 
Substring matching attribute selectors</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-ol-element">
   <a href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-ol-element">https://html.spec.whatwg.org/multipage/grouping-content.html#the-ol-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-ol-element">4.2. 
The Matches-Any Pseudo-class: :is()</a>
    <li><a href="#ref-for-the-ol-element①">14.2. 
Child combinator (>)</a> <a href="#ref-for-the-ol-element②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-option-element">
   <a href="https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element">https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-option-element">12.1.3. 
The Placeholder-shown Pseudo-class: :placeholder-shown</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-p-element">
   <a href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element">https://html.spec.whatwg.org/multipage/grouping-content.html#the-p-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-p-element">6.6. 
Class selectors</a>
    <li><a href="#ref-for-the-p-element①">8.4. 
The Target Pseudo-class: :target</a>
    <li><a href="#ref-for-the-p-element②">12.3.2. 
The Validity Pseudo-classes: :valid and :invalid</a>
    <li><a href="#ref-for-the-p-element③">13.2. 
:empty pseudo-class</a>
    <li><a href="#ref-for-the-p-element④">13.3.3. 
:first-child pseudo-class</a>
    <li><a href="#ref-for-the-p-element⑤">14.1. 
Descendant combinator ( )</a>
    <li><a href="#ref-for-the-p-element⑥">14.2. 
Child combinator (>)</a> <a href="#ref-for-the-p-element⑦">(2)</a>
    <li><a href="#ref-for-the-p-element⑧">14.3. 
Next-sibling combinator (+)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-attr-input-placeholder">
   <a href="https://html.spec.whatwg.org/multipage/input.html#attr-input-placeholder">https://html.spec.whatwg.org/multipage/input.html#attr-input-placeholder</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-attr-input-placeholder">12.1.3. 
The Placeholder-shown Pseudo-class: :placeholder-shown</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-pre-element">
   <a href="https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element">https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-pre-element">14.4. 
Subsequent-sibling combinator (~)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-q-element">
   <a href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-q-element">https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-q-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-q-element">7.2. 
The Language Pseudo-class: :lang()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-select-element">
   <a href="https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element">https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-select-element">12.1.3. 
The Placeholder-shown Pseudo-class: :placeholder-shown</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-span-element">
   <a href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-span-element">https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-span-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-span-element">6.1. 
Attribute presence and value selectors</a> <a href="#ref-for-the-span-element①">(2)</a>
    <li><a href="#ref-for-the-span-element②">6.6. 
Class selectors</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-the-textarea-element">
   <a href="https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element">https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-the-textarea-element">12.3.1. 
The Empty-Value Pseudo-class: :blank</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-attr-input-value">
   <a href="https://html.spec.whatwg.org/multipage/input.html#attr-input-value">https://html.spec.whatwg.org/multipage/input.html#attr-input-value</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-attr-input-value">12.3.1. 
The Empty-Value Pseudo-class: :blank</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ascii-case-insensitive">
   <a href="https://infra.spec.whatwg.org/#ascii-case-insensitive">https://infra.spec.whatwg.org/#ascii-case-insensitive</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ascii-case-insensitive">3.5. 
Pseudo-classes</a>
    <li><a href="#ref-for-ascii-case-insensitive①">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-ascii-case-insensitive②">6.6. 
Class selectors</a>
    <li><a href="#ref-for-ascii-case-insensitive③">6.7. 
ID selectors</a>
    <li><a href="#ref-for-ascii-case-insensitive④">20. 
Appendix B: Obsolete but Required Parsing Quirks for Web Compat</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-x">
   <a href="https://drafts.csswg.org/selectors-3/#x">https://drafts.csswg.org/selectors-3/#x</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-x">3.6.2. 
Binding to the Document Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-sel-lang">
   <a href="https://drafts.csswg.org/selectors-3/#sel-lang">https://drafts.csswg.org/selectors-3/#sel-lang</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-sel-lang">6.1. 
Attribute presence and value selectors</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-elementdef-a">
   <a href="https://svgwg.org/svg2-draft/linking.html#elementdef-a">https://svgwg.org/svg2-draft/linking.html#elementdef-a</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-elementdef-a">3.3. 
Scoped Selectors</a> <a href="#ref-for-elementdef-a①">(2)</a>
    <li><a href="#ref-for-elementdef-a②">6.1. 
Attribute presence and value selectors</a> <a href="#ref-for-elementdef-a③">(2)</a> <a href="#ref-for-elementdef-a④">(3)</a> <a href="#ref-for-elementdef-a⑤">(4)</a> <a href="#ref-for-elementdef-a⑥">(5)</a>
    <li><a href="#ref-for-elementdef-a⑦">6.2. 
Substring matching attribute selectors</a>
    <li><a href="#ref-for-elementdef-a⑧">8.1. 
The Hyperlink Pseudo-class: :any-link</a>
    <li><a href="#ref-for-elementdef-a⑨">9. 
User Action Pseudo-classes</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-LinkElement">
   <a href="https://svgwg.org/svg2-draft/styling.html#LinkElement">https://svgwg.org/svg2-draft/styling.html#LinkElement</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-LinkElement">8.1. 
The Hyperlink Pseudo-class: :any-link</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-concept-url-fragment">
   <a href="https://url.spec.whatwg.org/#concept-url-fragment">https://url.spec.whatwg.org/#concept-url-fragment</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-url-fragment">8.4. 
The Target Pseudo-class: :target</a>
   </ul>
  </aside>
  <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3>
  <ul class="index">
   <li>
    <a data-link-type="biblio">[css-display-3]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-box tree" style="color:initial">box tree</span>
     <li><span class="dfn-paneled" id="term-for-propdef-display" style="color:initial">display</span>
    </ul>
   <li>
    <a data-link-type="biblio">[CSS-PSEUDO-4]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-selectordef-after" style="color:initial">::after</span>
     <li><span class="dfn-paneled" id="term-for-selectordef-before" style="color:initial">::before</span>
     <li><span class="dfn-paneled" id="term-for-selectordef-first-letter" style="color:initial">::first-letter</span>
     <li><span class="dfn-paneled" id="term-for-selectordef-first-line" style="color:initial">::first-line</span>
     <li><span class="dfn-paneled" id="term-for-tree-abiding" style="color:initial">tree-abiding pseudo-element</span>
    </ul>
   <li>
    <a data-link-type="biblio">[css-scoping-1]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-selectordef-content" style="color:initial">::content</span>
     <li><span class="dfn-paneled" id="term-for-selectordef-shadow" style="color:initial">::shadow</span>
     <li><span class="dfn-paneled" id="term-for-selectordef-slotted" style="color:initial">::slotted()</span>
     <li><span class="dfn-paneled" id="term-for-selectordef-host" style="color:initial">:host</span>
     <li><span class="dfn-paneled" id="term-for-selectordef-host-context" style="color:initial">:host-context()</span>
     <li><span class="dfn-paneled" id="term-for-flat-tree" style="color:initial">flat tree</span>
    </ul>
   <li>
    <a data-link-type="biblio">[css-text-3]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-content-language" style="color:initial">content language</span>
     <li><span class="dfn-paneled" id="term-for-white-space" style="color:initial">document white space characters</span>
    </ul>
   <li>
    <a data-link-type="biblio">[css-values-3]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-string-value" style="color:initial">&lt;string></span>
    </ul>
   <li>
    <a data-link-type="biblio">[css-values-4]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-mult-req" style="color:initial">!</span>
     <li><span class="dfn-paneled" id="term-for-mult-comma" style="color:initial">#</span>
     <li><span class="dfn-paneled" id="term-for-mult-zero-plus" style="color:initial">*</span>
     <li><span class="dfn-paneled" id="term-for-typedef-ident" style="color:initial">&lt;ident></span>
     <li><span class="dfn-paneled" id="term-for-mult-opt" style="color:initial">?</span>
     <li><span class="dfn-paneled" id="term-for-comb-one" style="color:initial">|</span>
    </ul>
   <li>
    <a data-link-type="biblio">[css-writing-modes-3]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-propdef-direction" style="color:initial">direction</span>
    </ul>
   <li>
    <a data-link-type="biblio">[CSS21]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-propdef-visibility" style="color:initial">visibility</span>
    </ul>
   <li>
    <a data-link-type="biblio">[CSS3NAMESPACE]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-css-qualified-name" style="color:initial">css qualified name</span>
     <li><span class="dfn-paneled" id="term-for-default-namespace" style="color:initial">default namespace</span>
    </ul>
   <li>
    <a data-link-type="biblio">[CSS3SYN]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-anb-production" style="color:initial">&lt;an+b></span>
     <li><span class="dfn-paneled" id="term-for-typedef-any-value" style="color:initial">&lt;any-value></span>
     <li><span class="dfn-paneled" id="term-for-typedef-function-token" style="color:initial">&lt;function-token></span>
     <li><span class="dfn-paneled" id="term-for-typedef-hash-token" style="color:initial">&lt;hash-token></span>
     <li><span class="dfn-paneled" id="term-for-typedef-ident-token" style="color:initial">&lt;ident-token></span>
     <li><span class="dfn-paneled" id="term-for-typedef-string-token" style="color:initial">&lt;string-token></span>
     <li><span class="dfn-paneled" id="term-for-identifier" style="color:initial">identifier</span>
     <li><span class="dfn-paneled" id="term-for-css-parse-something-according-to-a-css-grammar" style="color:initial">parse</span>
    </ul>
   <li>
    <a data-link-type="biblio">[DOM]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-document" style="color:initial">Document</span>
     <li><span class="dfn-paneled" id="term-for-documentfragment" style="color:initial">DocumentFragment</span>
     <li><span class="dfn-paneled" id="term-for-concept-tree-descendant" style="color:initial">descendant</span>
     <li><span class="dfn-paneled" id="term-for-concept-tree-inclusive-sibling" style="color:initial">inclusive sibling</span>
     <li><span class="dfn-paneled" id="term-for-concept-document-quirks" style="color:initial">quirks mode</span>
     <li><span class="dfn-paneled" id="term-for-concept-tree-root" style="color:initial">root</span>
     <li><span class="dfn-paneled" id="term-for-element-shadow-host" style="color:initial">shadow host</span>
     <li><span class="dfn-paneled" id="term-for-concept-shadow-tree" style="color:initial">shadow tree</span>
     <li><span class="dfn-paneled" id="term-for-concept-shadow-including-tree-order" style="color:initial">shadow-including tree order</span>
     <li><span class="dfn-paneled" id="term-for-concept-tree" style="color:initial">tree</span>
    </ul>
   <li>
    <a data-link-type="biblio">[HTML]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-the-area-element" style="color:initial">area</span>
     <li><span class="dfn-paneled" id="term-for-the-button-element" style="color:initial">button</span>
     <li><span class="dfn-paneled" id="term-for-the-div-element" style="color:initial">div</span>
     <li><span class="dfn-paneled" id="term-for-the-em-element" style="color:initial">em</span>
     <li><span class="dfn-paneled" id="term-for-the-html-element" style="color:initial">html</span>
     <li><span class="dfn-paneled" id="term-for-the-img-element" style="color:initial">img</span>
     <li><span class="dfn-paneled" id="term-for-the-input-element" style="color:initial">input</span>
     <li><span class="dfn-paneled" id="term-for-the-label-element" style="color:initial">label</span>
     <li><span class="dfn-paneled" id="term-for-the-li-element" style="color:initial">li</span>
     <li><span class="dfn-paneled" id="term-for-meta" style="color:initial">meta</span>
     <li><span class="dfn-paneled" id="term-for-the-object-element" style="color:initial">object</span>
     <li><span class="dfn-paneled" id="term-for-the-ol-element" style="color:initial">ol</span>
     <li><span class="dfn-paneled" id="term-for-the-option-element" style="color:initial">option</span>
     <li><span class="dfn-paneled" id="term-for-the-p-element" style="color:initial">p</span>
     <li><span class="dfn-paneled" id="term-for-attr-input-placeholder" style="color:initial">placeholder</span>
     <li><span class="dfn-paneled" id="term-for-the-pre-element" style="color:initial">pre</span>
     <li><span class="dfn-paneled" id="term-for-the-q-element" style="color:initial">q</span>
     <li><span class="dfn-paneled" id="term-for-the-select-element" style="color:initial">select</span>
     <li><span class="dfn-paneled" id="term-for-the-span-element" style="color:initial">span</span>
     <li><span class="dfn-paneled" id="term-for-the-textarea-element" style="color:initial">textarea</span>
     <li><span class="dfn-paneled" id="term-for-attr-input-value" style="color:initial">value</span>
    </ul>
   <li>
    <a data-link-type="biblio">[INFRA]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-ascii-case-insensitive" style="color:initial">ascii case-insensitive</span>
    </ul>
   <li>
    <a data-link-type="biblio">[SELECT]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-x" style="color:initial">*</span>
     <li><span class="dfn-paneled" id="term-for-sel-lang" style="color:initial">:lang</span>
    </ul>
   <li>
    <a data-link-type="biblio">[SVG2]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-elementdef-a" style="color:initial">a</span>
     <li><span class="dfn-paneled" id="term-for-LinkElement" style="color:initial">link</span>
    </ul>
   <li>
    <a data-link-type="biblio">[URL]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-concept-url-fragment" style="color:initial">fragment</span>
    </ul>
  </ul>
  <h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2>
  <h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3>
  <dl>
   <dt id="biblio-css-display-3">[CSS-DISPLAY-3]
   <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://www.w3.org/TR/css-display-3/">CSS Display Module Level 3</a>. 28 August 2018. CR. URL: <a href="https://www.w3.org/TR/css-display-3/">https://www.w3.org/TR/css-display-3/</a>
   <dt id="biblio-css-pseudo-4">[CSS-PSEUDO-4]
   <dd>Daniel Glazman; Elika Etemad; Alan Stearns. <a href="https://www.w3.org/TR/css-pseudo-4/">CSS Pseudo-Elements Module Level 4</a>. 25 February 2019. WD. URL: <a href="https://www.w3.org/TR/css-pseudo-4/">https://www.w3.org/TR/css-pseudo-4/</a>
   <dt id="biblio-css-scoping-1">[CSS-SCOPING-1]
   <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://www.w3.org/TR/css-scoping-1/">CSS Scoping Module Level 1</a>. 3 April 2014. WD. URL: <a href="https://www.w3.org/TR/css-scoping-1/">https://www.w3.org/TR/css-scoping-1/</a>
   <dt id="biblio-css-text-3">[CSS-TEXT-3]
   <dd>Elika Etemad; Koji Ishii; Florian Rivoal. <a href="https://www.w3.org/TR/css-text-3/">CSS Text Module Level 3</a>. 12 December 2018. WD. URL: <a href="https://www.w3.org/TR/css-text-3/">https://www.w3.org/TR/css-text-3/</a>
   <dt id="biblio-css-values-3">[CSS-VALUES-3]
   <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://www.w3.org/TR/css-values-3/">CSS Values and Units Module Level 3</a>. 31 January 2019. CR. URL: <a href="https://www.w3.org/TR/css-values-3/">https://www.w3.org/TR/css-values-3/</a>
   <dt id="biblio-css-values-4">[CSS-VALUES-4]
   <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://www.w3.org/TR/css-values-4/">CSS Values and Units Module Level 4</a>. 31 January 2019. WD. URL: <a href="https://www.w3.org/TR/css-values-4/">https://www.w3.org/TR/css-values-4/</a>
   <dt id="biblio-css-writing-modes-3">[CSS-WRITING-MODES-3]
   <dd>Elika Etemad; Koji Ishii. <a href="https://www.w3.org/TR/css-writing-modes-3/">CSS Writing Modes Level 3</a>. 24 May 2018. CR. URL: <a href="https://www.w3.org/TR/css-writing-modes-3/">https://www.w3.org/TR/css-writing-modes-3/</a>
   <dt id="biblio-css21">[CSS21]
   <dd>Bert Bos; et al. <a href="https://www.w3.org/TR/CSS2/">Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</a>. 7 June 2011. REC. URL: <a href="https://www.w3.org/TR/CSS2/">https://www.w3.org/TR/CSS2/</a>
   <dt id="biblio-css3namespace">[CSS3NAMESPACE]
   <dd>Elika Etemad. <a href="https://www.w3.org/TR/css-namespaces-3/">CSS Namespaces Module Level 3</a>. 20 March 2014. REC. URL: <a href="https://www.w3.org/TR/css-namespaces-3/">https://www.w3.org/TR/css-namespaces-3/</a>
   <dt id="biblio-css3syn">[CSS3SYN]
   <dd>Tab Atkins Jr.; Simon Sapin. <a href="https://www.w3.org/TR/css-syntax-3/">CSS Syntax Module Level 3</a>. 20 February 2014. CR. URL: <a href="https://www.w3.org/TR/css-syntax-3/">https://www.w3.org/TR/css-syntax-3/</a>
   <dt id="biblio-dom">[DOM]
   <dd>Anne van Kesteren. <a href="https://dom.spec.whatwg.org/">DOM Standard</a>. Living Standard. URL: <a href="https://dom.spec.whatwg.org/">https://dom.spec.whatwg.org/</a>
   <dt id="biblio-html">[HTML]
   <dd>Anne van Kesteren; et al. <a href="https://html.spec.whatwg.org/multipage/">HTML Standard</a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a>
   <dt id="biblio-infra">[INFRA]
   <dd>Anne van Kesteren; Domenic Denicola. <a href="https://infra.spec.whatwg.org/">Infra Standard</a>. Living Standard. URL: <a href="https://infra.spec.whatwg.org/">https://infra.spec.whatwg.org/</a>
   <dt id="biblio-rfc2119">[RFC2119]
   <dd>S. Bradner. <a href="https://tools.ietf.org/html/rfc2119">Key words for use in RFCs to Indicate Requirement Levels</a>. March 1997. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc2119">https://tools.ietf.org/html/rfc2119</a>
   <dt id="biblio-select">[SELECT]
   <dd>Tantek Çelik; et al. <a href="https://www.w3.org/TR/selectors-3/">Selectors Level 3</a>. 6 November 2018. REC. URL: <a href="https://www.w3.org/TR/selectors-3/">https://www.w3.org/TR/selectors-3/</a>
   <dt id="biblio-svg2">[SVG2]
   <dd>Amelia Bellamy-Royds; et al. <a href="https://www.w3.org/TR/SVG2/">Scalable Vector Graphics (SVG) 2</a>. 4 October 2018. CR. URL: <a href="https://www.w3.org/TR/SVG2/">https://www.w3.org/TR/SVG2/</a>
   <dt id="biblio-url">[URL]
   <dd>Anne van Kesteren. <a href="https://url.spec.whatwg.org/">URL Standard</a>. Living Standard. URL: <a href="https://url.spec.whatwg.org/">https://url.spec.whatwg.org/</a>
  </dl>
  <h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3>
  <dl>
   <dt id="biblio-bcp47">[BCP47]
   <dd>A. Phillips; M. Davis. <a href="https://tools.ietf.org/html/bcp47">Tags for Identifying Languages</a>. September 2009. IETF Best Current Practice. URL: <a href="https://tools.ietf.org/html/bcp47">https://tools.ietf.org/html/bcp47</a>
   <dt id="biblio-css3ui">[CSS3UI]
   <dd>Tantek Çelik; Florian Rivoal. <a href="https://www.w3.org/TR/css-ui-3/">CSS Basic User Interface Module Level 3 (CSS3 UI)</a>. 21 June 2018. REC. URL: <a href="https://www.w3.org/TR/css-ui-3/">https://www.w3.org/TR/css-ui-3/</a>
   <dt id="biblio-cssstyleattr">[CSSSTYLEATTR]
   <dd>Tantek Çelik; Elika Etemad. <a href="https://www.w3.org/TR/css-style-attr/">CSS Style Attributes</a>. 7 November 2013. REC. URL: <a href="https://www.w3.org/TR/css-style-attr/">https://www.w3.org/TR/css-style-attr/</a>
   <dt id="biblio-html5">[HTML5]
   <dd>Ian Hickson; et al. <a href="https://www.w3.org/TR/html5/">HTML5</a>. 27 March 2018. REC. URL: <a href="https://www.w3.org/TR/html5/">https://www.w3.org/TR/html5/</a>
   <dt id="biblio-its20">[ITS20]
   <dd>David Filip; et al. <a href="https://www.w3.org/TR/its20/">Internationalization Tag Set (ITS) Version 2.0</a>. 29 October 2013. REC. URL: <a href="https://www.w3.org/TR/its20/">https://www.w3.org/TR/its20/</a>
   <dt id="biblio-mathml">[MATHML]
   <dd>Patrick D F Ion; Robert R Miner. <a href="https://www.w3.org/TR/REC-MathML/">Mathematical Markup Language (MathML) 1.01 Specification</a>. 7 July 1999. REC. URL: <a href="https://www.w3.org/TR/REC-MathML/">https://www.w3.org/TR/REC-MathML/</a>
   <dt id="biblio-quirks">[QUIRKS]
   <dd>Simon Pieters. <a href="https://quirks.spec.whatwg.org/">Quirks Mode Standard</a>. Living Standard. URL: <a href="https://quirks.spec.whatwg.org/">https://quirks.spec.whatwg.org/</a>
   <dt id="biblio-rfc4647">[RFC4647]
   <dd>A. Phillips; M. Davis. <a href="https://tools.ietf.org/html/rfc4647">Matching of Language Tags</a>. September 2006. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc4647">https://tools.ietf.org/html/rfc4647</a>
   <dt id="biblio-svg11">[SVG11]
   <dd>Erik Dahlström; et al. <a href="https://www.w3.org/TR/SVG11/">Scalable Vector Graphics (SVG) 1.1 (Second Edition)</a>. 16 August 2011. REC. URL: <a href="https://www.w3.org/TR/SVG11/">https://www.w3.org/TR/SVG11/</a>
   <dt id="biblio-xforms11">[XFORMS11]
   <dd>John Boyer. <a href="https://www.w3.org/TR/xforms11/">XForms 1.1</a>. 20 October 2009. REC. URL: <a href="https://www.w3.org/TR/xforms11/">https://www.w3.org/TR/xforms11/</a>
   <dt id="biblio-xml-names">[XML-NAMES]
   <dd>Tim Bray; et al. <a href="https://www.w3.org/TR/xml-names/">Namespaces in XML 1.0 (Third Edition)</a>. 8 December 2009. REC. URL: <a href="https://www.w3.org/TR/xml-names/">https://www.w3.org/TR/xml-names/</a>
   <dt id="biblio-xml10">[XML10]
   <dd>Tim Bray; et al. <a href="https://www.w3.org/TR/xml/">Extensible Markup Language (XML) 1.0 (Fifth Edition)</a>. 26 November 2008. REC. URL: <a href="https://www.w3.org/TR/xml/">https://www.w3.org/TR/xml/</a>
  </dl>
  <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content">Issues Index</span><a class="self-link" href="#issues-index"></a></h2>
  <div style="counter-reset:issue">
   <div class="issue"> The categorization of things into the “live” or snapshot profiles needs implementor review.
		If some things currently not in the live profile can reasonably be done in CSS Selectors,
		we should move them. <a href="#issue-77669937"> ↵ </a></div>
   <div class="issue"> Pseudo-elements aren’t handled here, and should be.<a href="#issue-5830d0c1"> ↵ </a></div>
   <div class="issue"> <a href="https://github.com/w3c/csswg-drafts/issues/2199">This needs a sane definition.</a><a href="#issue-28dbdaca"> ↵ </a></div>
   <div class="issue"> Clarify that <a class="css" data-link-type="maybe" href="#negation-pseudo">:not()</a> and <a class="css" data-link-type="maybe" href="#matches-pseudo">:is()</a> can be used when containing above-mentioned pseudos.<a href="#issue-9f34fdb4"> ↵ </a></div>
   <div class="issue"> Does <span class="css">::first-line:not(:focus)</span> match anything?<a href="#issue-27c4806a"> ↵ </a></div>
   <div class="issue"> The CSSWG indends to modify these rules such that an invalid selector
	in the selector list argument of a pseudo-class like `:is()`
	is simply ignored rather than invalidating the whole selector list.
	See <a href="https://github.com/w3c/csswg-drafts/issues/3264">Issue 3264</a>.<a href="#issue-897fe327"> ↵ </a></div>
   <div class="issue">Add comma-separated syntax for <a href="http://lists.w3.org/Archives/Public/www-style/2011Mar/0215.html">multiple-value matching</a>?
	e.g. [rel ~= next, prev, up, first, last] <a href="#issue-745ef775"> ↵ </a></div>
   <div class="issue"> There’s a desire from authors to propagate <a class="css" data-link-type="maybe" href="#focus-pseudo">:focus</a> from a form control to its associated <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/forms.html#the-label-element">label</a></code> element;
	the main objection seems to be implementation difficulty.
	See <a href="https://github.com/w3c/csswg-drafts/issues/397">CSSWG issue (CSS)</a> and <a href="https://github.com/whatwg/html/issues/1632">WHATWG issue (HTML)</a>.<a href="#issue-1416193e"> ↵ </a></div>
   <div class="issue"> Cross-check with <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/%3A-moz-ui-invalid"><span class="css">:-moz-ui-invalid</span></a>.<a href="#issue-b776312b"> ↵ </a></div>
   <div class="issue"> Add <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/%3A-moz-ui-valid">:-moz-ui-valid</a> as <span class="css">:user-valid</span> per WG resolution.<a href="#issue-fcbee641"> ↵ </a></div>
   <div class="issue"> Evaluate proposed <a href="https://lists.w3.org/Archives/Public/www-style/2014Feb/0511.html">:dirty pseudo-class</a><a href="#issue-a71d9d5b"> ↵ </a></div>
   <div class="issue"> Clarify that this (and <a class="css" data-link-type="maybe" href="#invalid-pseudo">:invalid</a>/<a class="css" data-link-type="maybe" href="#valid-pseudo">:valid</a>) can apply to form and fieldset elements.<a href="#issue-df919919"> ↵ </a></div>
   <div class="issue"> Are these still necessary now that we have more rigorous definitions for <a data-link-type="dfn" href="#match">match</a> and <a data-link-type="dfn" href="#invalid-selector">invalid selector</a>?
	Nouns are a lot easier to coordinate across specification than predicates,
	and details like the exact order of elements returned from <code>querySelector</code> seem to make more sense being defined in the DOM specification than in Selectors.<a href="#issue-55d7bd68"> ↵ </a></div>
   <div class="issue"> Should it instead default to the root element,
			to match the definition of <a class="css" data-link-type="maybe" href="#scope-pseudo">:scope</a>?<a href="#issue-8e6907ff"> ↵ </a></div>
   <div class="issue"> This is now redundant with the <var>root elements</var>.<a href="#issue-298e030f"> ↵ </a></div>
   <div class="issue"> Only the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-before">::before</a> and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-after">::after</a> pseudo-elements are really
			handled in any way remotely like this.<a href="#issue-eaeaf8e2"> ↵ </a></div>
   <div class="issue"> The relative position of pseudo-elements
				in <var>selector match list</var> is undefined.
				There’s not yet a context that exposes this information,
				but we need to decide on something eventually,
				before something <em>is</em> exposed.<a href="#issue-b7f52036"> ↵ </a></div>
   <div class="issue"> Some pseudo-classes are *syntactical*,
			like <a class="css" data-link-type="maybe" href="#has-pseudo">:has()</a> and <a class="css" data-link-type="maybe" href="#matches-pseudo">:is()</a>,
			and thus should always work.
			Need to indicate that somewhere.
			Probably the structural pseudos always work
			whenever the child list is ordered.<a href="#issue-772ec278"> ↵ </a></div>
   <div class="issue"> Semantic definition should probably move back here.<a href="#issue-fb60ae39"> ↵ </a></div>
   <div class="issue"> Need to define tree for XML.<a href="#issue-4ca3978c"> ↵ </a></div>
  </div>
  <aside class="dfn-panel" data-for="live-profile">
   <b><a href="#live-profile">#live-profile</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-live-profile">2.1. 
Live vs Snapshot Selector Profiles</a> <a href="#ref-for-live-profile①">(2)</a> <a href="#ref-for-live-profile②">(3)</a> <a href="#ref-for-live-profile③">(4)</a>
    <li><a href="#ref-for-live-profile④">21.3. 
Changes since the 23 August 2012 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="snapshot-profile">
   <b><a href="#snapshot-profile">#snapshot-profile</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-snapshot-profile">2.1. 
Live vs Snapshot Selector Profiles</a> <a href="#ref-for-snapshot-profile①">(2)</a> <a href="#ref-for-snapshot-profile②">(3)</a>
    <li><a href="#ref-for-snapshot-profile③">21.3. 
Changes since the 23 August 2012 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selector">
   <b><a href="#selector">#selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selector①">1. 
Introduction</a>
    <li><a href="#ref-for-selector②">3.1. 
Structure and Terminology</a> <a href="#ref-for-selector③">(2)</a> <a href="#ref-for-selector④">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selector-subject">
   <b><a href="#selector-subject">#selector-subject</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selector-subject">3.1. 
Structure and Terminology</a>
    <li><a href="#ref-for-selector-subject①">4.2. 
The Matches-Any Pseudo-class: :is()</a>
    <li><a href="#ref-for-selector-subject②">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="match">
   <b><a href="#match">#match</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-match">3.1. 
Structure and Terminology</a> <a href="#ref-for-match①">(2)</a> <a href="#ref-for-match②">(3)</a> <a href="#ref-for-match③">(4)</a> <a href="#ref-for-match④">(5)</a>
    <li><a href="#ref-for-match⑤">18. 
API Hooks</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="simple">
   <b><a href="#simple">#simple</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-simple">3.1. 
Structure and Terminology</a> <a href="#ref-for-simple①">(2)</a> <a href="#ref-for-simple②">(3)</a> <a href="#ref-for-simple③">(4)</a> <a href="#ref-for-simple④">(5)</a> <a href="#ref-for-simple⑤">(6)</a> <a href="#ref-for-simple⑥">(7)</a> <a href="#ref-for-simple⑦">(8)</a> <a href="#ref-for-simple⑧">(9)</a>
    <li><a href="#ref-for-simple⑨">3.5. 
Pseudo-classes</a> <a href="#ref-for-simple①⓪">(2)</a>
    <li><a href="#ref-for-simple①①">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a>
    <li><a href="#ref-for-simple①②">5.2. 
Universal selector </a>
    <li><a href="#ref-for-simple①③">18.4. 
Match a Selector Against a Pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="compound">
   <b><a href="#compound">#compound</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-compound">2. 
Selectors Overview</a> <a href="#ref-for-compound①">(2)</a> <a href="#ref-for-compound②">(3)</a> <a href="#ref-for-compound③">(4)</a> <a href="#ref-for-compound④">(5)</a> <a href="#ref-for-compound⑤">(6)</a>
    <li><a href="#ref-for-compound⑥">3.1. 
Structure and Terminology</a> <a href="#ref-for-compound⑦">(2)</a> <a href="#ref-for-compound⑧">(3)</a> <a href="#ref-for-compound⑨">(4)</a> <a href="#ref-for-compound①⓪">(5)</a> <a href="#ref-for-compound①①">(6)</a> <a href="#ref-for-compound①②">(7)</a> <a href="#ref-for-compound①③">(8)</a> <a href="#ref-for-compound①④">(9)</a> <a href="#ref-for-compound①⑤">(10)</a> <a href="#ref-for-compound①⑥">(11)</a> <a href="#ref-for-compound①⑦">(12)</a> <a href="#ref-for-compound①⑧">(13)</a>
    <li><a href="#ref-for-compound①⑨">3.4.1. 
Absolutizing a Relative Selector</a>
    <li><a href="#ref-for-compound②⓪">3.5. 
Pseudo-classes</a> <a href="#ref-for-compound②①">(2)</a>
    <li><a href="#ref-for-compound②②">3.6.2. 
Binding to the Document Tree</a> <a href="#ref-for-compound②③">(2)</a>
    <li><a href="#ref-for-compound②④">3.9. 
Invalid Selectors and Error Handling</a>
    <li><a href="#ref-for-compound②⑤">4.2. 
The Matches-Any Pseudo-class: :is()</a>
    <li><a href="#ref-for-compound②⑥">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a>
    <li><a href="#ref-for-compound②⑦">5.2. 
Universal selector </a> <a href="#ref-for-compound②⑧">(2)</a>
    <li><a href="#ref-for-compound②⑨">5.3. 
Namespaces in Elemental Selectors</a>
    <li><a href="#ref-for-compound③⓪">10.1. 
The Current-element Pseudo-class: :current</a>
    <li><a href="#ref-for-compound③①">14.1. 
Descendant combinator ( )</a>
    <li><a href="#ref-for-compound③②">14.2. 
Child combinator (>)</a>
    <li><a href="#ref-for-compound③③">14.3. 
Next-sibling combinator (+)</a> <a href="#ref-for-compound③④">(2)</a> <a href="#ref-for-compound③⑤">(3)</a>
    <li><a href="#ref-for-compound③⑥">14.4. 
Subsequent-sibling combinator (~)</a> <a href="#ref-for-compound③⑦">(2)</a>
    <li><a href="#ref-for-compound③⑧">18.3. 
Match a Selector Against an Element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selector-combinator">
   <b><a href="#selector-combinator">#selector-combinator</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selector-combinator">3.1. 
Structure and Terminology</a> <a href="#ref-for-selector-combinator①">(2)</a> <a href="#ref-for-selector-combinator②">(3)</a> <a href="#ref-for-selector-combinator③">(4)</a> <a href="#ref-for-selector-combinator④">(5)</a> <a href="#ref-for-selector-combinator⑤">(6)</a>
    <li><a href="#ref-for-selector-combinator⑥">3.4. 
Relative Selectors</a>
    <li><a href="#ref-for-selector-combinator⑦">3.4.1. 
Absolutizing a Relative Selector</a>
    <li><a href="#ref-for-selector-combinator⑧">3.6.4. 
Internal Structure</a>
    <li><a href="#ref-for-selector-combinator⑨">18.3. 
Match a Selector Against an Element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="complex">
   <b><a href="#complex">#complex</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-complex">3.1. 
Structure and Terminology</a> <a href="#ref-for-complex①">(2)</a> <a href="#ref-for-complex②">(3)</a> <a href="#ref-for-complex③">(4)</a> <a href="#ref-for-complex④">(5)</a>
    <li><a href="#ref-for-complex⑤">3.4. 
Relative Selectors</a>
    <li><a href="#ref-for-complex⑥">13.3.1. 
:nth-child() pseudo-class</a>
    <li><a href="#ref-for-complex⑦">16. 
Calculating a selector’s specificity</a> <a href="#ref-for-complex⑧">(2)</a>
    <li><a href="#ref-for-complex⑨">18.3. 
Match a Selector Against an Element</a>
    <li><a href="#ref-for-complex①⓪">18.4. 
Match a Selector Against a Pseudo-element</a> <a href="#ref-for-complex①①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="list-of-simple-selectors">
   <b><a href="#list-of-simple-selectors">#list-of-simple-selectors</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-list-of-simple-selectors">3.1. 
Structure and Terminology</a>
    <li><a href="#ref-for-list-of-simple-selectors①">18.3. 
Match a Selector Against an Element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selector-list">
   <b><a href="#selector-list">#selector-list</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selector-list">3.1. 
Structure and Terminology</a> <a href="#ref-for-selector-list①">(2)</a> <a href="#ref-for-selector-list②">(3)</a> <a href="#ref-for-selector-list③">(4)</a>
    <li><a href="#ref-for-selector-list④">4.1. 
Selector Lists</a> <a href="#ref-for-selector-list⑤">(2)</a>
    <li><a href="#ref-for-selector-list⑥">4.2. 
The Matches-Any Pseudo-class: :is()</a>
    <li><a href="#ref-for-selector-list⑦">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a>
    <li><a href="#ref-for-selector-list⑧">4.5. 
The Relational Pseudo-class: :has()</a>
    <li><a href="#ref-for-selector-list⑨">13.3.1. 
:nth-child() pseudo-class</a>
    <li><a href="#ref-for-selector-list①⓪">13.3.2. 
:nth-last-child() pseudo-class</a>
    <li><a href="#ref-for-selector-list①①">16. 
Calculating a selector’s specificity</a> <a href="#ref-for-selector-list①②">(2)</a> <a href="#ref-for-selector-list①③">(3)</a>
    <li><a href="#ref-for-selector-list①④">21.2. 
Changes since the 2 May 2013 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="featureless">
   <b><a href="#featureless">#featureless</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-featureless">3.2. 
Data Model</a> <a href="#ref-for-featureless①">(2)</a> <a href="#ref-for-featureless②">(3)</a>
    <li><a href="#ref-for-featureless③">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-featureless④">5.2. 
Universal selector </a> <a href="#ref-for-featureless⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="document-language">
   <b><a href="#document-language">#document-language</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-document-language">3.1. 
Structure and Terminology</a>
    <li><a href="#ref-for-document-language①">3.2. 
Data Model</a>
    <li><a href="#ref-for-document-language②">7.1. 
The Directionality Pseudo-class: :dir()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="host-language">
   <b><a href="#host-language">#host-language</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-host-language">3.2. 
Data Model</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="scoped-selector">
   <b><a href="#scoped-selector">#scoped-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-scoped-selector">3.3. 
Scoped Selectors</a> <a href="#ref-for-scoped-selector①">(2)</a>
    <li><a href="#ref-for-scoped-selector②">3.4. 
Relative Selectors</a>
    <li><a href="#ref-for-scoped-selector③">3.4.1. 
Absolutizing a Relative Selector</a>
    <li><a href="#ref-for-scoped-selector④">8.6. 
The Reference Element Pseudo-class: :scope</a> <a href="#ref-for-scoped-selector⑤">(2)</a>
    <li><a href="#ref-for-scoped-selector⑥">18.5. 
Match a Selector Against a Tree</a> <a href="#ref-for-scoped-selector⑦">(2)</a>
    <li><a href="#ref-for-scoped-selector⑧">21.2. 
Changes since the 2 May 2013 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="scoping-root">
   <b><a href="#scoping-root">#scoping-root</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-scoping-root">3.3. 
Scoped Selectors</a> <a href="#ref-for-scoping-root①">(2)</a>
    <li><a href="#ref-for-scoping-root②">8.6. 
The Reference Element Pseudo-class: :scope</a> <a href="#ref-for-scoping-root③">(2)</a> <a href="#ref-for-scoping-root④">(3)</a>
    <li><a href="#ref-for-scoping-root⑤">18.5. 
Match a Selector Against a Tree</a> <a href="#ref-for-scoping-root⑥">(2)</a> <a href="#ref-for-scoping-root⑦">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="virtual-scoping-root">
   <b><a href="#virtual-scoping-root">#virtual-scoping-root</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-virtual-scoping-root">3.4.1. 
Absolutizing a Relative Selector</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="relative-selector">
   <b><a href="#relative-selector">#relative-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-relative-selector">2. 
Selectors Overview</a>
    <li><a href="#ref-for-relative-selector①">3.4. 
Relative Selectors</a>
    <li><a href="#ref-for-relative-selector②">4.5. 
The Relational Pseudo-class: :has()</a> <a href="#ref-for-relative-selector③">(2)</a>
    <li><a href="#ref-for-relative-selector④">18.3. 
Match a Selector Against an Element</a>
    <li><a href="#ref-for-relative-selector⑤">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-relative-selector⑥">21.3. 
Changes since the 23 August 2012 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="absolutize">
   <b><a href="#absolutize">#absolutize</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-absolutize">3.4. 
Relative Selectors</a>
    <li><a href="#ref-for-absolutize">4.5. 
The Relational Pseudo-class: :has()</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="absolutize-list">
   <b><a href="#absolutize-list">#absolutize-list</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-absolutize-list">18.2. 
Parse A Relative Selector</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="pseudo-class">
   <b><a href="#pseudo-class">#pseudo-class</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-pseudo-class">3.1. 
Structure and Terminology</a>
    <li><a href="#ref-for-pseudo-class①">3.2. 
Data Model</a>
    <li><a href="#ref-for-pseudo-class②">3.5. 
Pseudo-classes</a> <a href="#ref-for-pseudo-class③">(2)</a> <a href="#ref-for-pseudo-class④">(3)</a> <a href="#ref-for-pseudo-class⑤">(4)</a> <a href="#ref-for-pseudo-class⑥">(5)</a> <a href="#ref-for-pseudo-class⑦">(6)</a> <a href="#ref-for-pseudo-class⑧">(7)</a>
    <li><a href="#ref-for-pseudo-class⑨">3.6. Pseudo-elements</a> <a href="#ref-for-pseudo-class①⓪">(2)</a>
    <li><a href="#ref-for-pseudo-class①①">3.6.3. 
Pseudo-classing Pseudo-elements</a> <a href="#ref-for-pseudo-class①②">(2)</a>
    <li><a href="#ref-for-pseudo-class①③">13.4.1. 
:nth-of-type() pseudo-class</a>
    <li><a href="#ref-for-pseudo-class①④">13.4.2. 
:nth-last-of-type() pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="functional-pseudo-class">
   <b><a href="#functional-pseudo-class">#functional-pseudo-class</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-functional-pseudo-class">3.5. 
Pseudo-classes</a> <a href="#ref-for-functional-pseudo-class①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="pseudo-element">
   <b><a href="#pseudo-element">#pseudo-element</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-pseudo-element">3.6. Pseudo-elements</a> <a href="#ref-for-pseudo-element①">(2)</a> <a href="#ref-for-pseudo-element②">(3)</a>
    <li><a href="#ref-for-pseudo-element③">3.6.1. 
Syntax</a> <a href="#ref-for-pseudo-element④">(2)</a> <a href="#ref-for-pseudo-element⑤">(3)</a> <a href="#ref-for-pseudo-element⑥">(4)</a> <a href="#ref-for-pseudo-element⑦">(5)</a> <a href="#ref-for-pseudo-element⑧">(6)</a>
    <li><a href="#ref-for-pseudo-element⑨">3.6.2. 
Binding to the Document Tree</a> <a href="#ref-for-pseudo-element①⓪">(2)</a> <a href="#ref-for-pseudo-element①①">(3)</a> <a href="#ref-for-pseudo-element①②">(4)</a> <a href="#ref-for-pseudo-element①③">(5)</a> <a href="#ref-for-pseudo-element①④">(6)</a>
    <li><a href="#ref-for-pseudo-element①⑤">3.6.3. 
Pseudo-classing Pseudo-elements</a> <a href="#ref-for-pseudo-element①⑥">(2)</a> <a href="#ref-for-pseudo-element①⑦">(3)</a> <a href="#ref-for-pseudo-element①⑧">(4)</a> <a href="#ref-for-pseudo-element①⑨">(5)</a>
    <li><a href="#ref-for-pseudo-element②⓪">3.6.4. 
Internal Structure</a> <a href="#ref-for-pseudo-element②①">(2)</a> <a href="#ref-for-pseudo-element②②">(3)</a>
    <li><a href="#ref-for-pseudo-element②③">13. 
Tree-Structural pseudo-classes</a>
    <li><a href="#ref-for-pseudo-element②④">17. 
Grammar</a> <a href="#ref-for-pseudo-element②⑤">(2)</a>
    <li><a href="#ref-for-pseudo-element②⑥">18.5. 
Match a Selector Against a Tree</a>
    <li><a href="#ref-for-pseudo-element②⑦">20. 
Appendix B: Obsolete but Required Parsing Quirks for Web Compat</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="originating-element">
   <b><a href="#originating-element">#originating-element</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-originating-element">3.6. Pseudo-elements</a>
    <li><a href="#ref-for-originating-element①">3.6.2. 
Binding to the Document Tree</a> <a href="#ref-for-originating-element②">(2)</a> <a href="#ref-for-originating-element③">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="whitespace">
   <b><a href="#whitespace">#whitespace</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-whitespace">3.5. 
Pseudo-classes</a> <a href="#ref-for-whitespace①">(2)</a>
    <li><a href="#ref-for-whitespace②">3.6.1. 
Syntax</a>
    <li><a href="#ref-for-whitespace">6.1. 
Attribute presence and value selectors</a>
    <li><a href="#ref-for-whitespace">6.6. 
Class selectors</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="nsdecl">
   <b><a href="#nsdecl">#nsdecl</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-nsdecl">5.3. 
Namespaces in Elemental Selectors</a> <a href="#ref-for-nsdecl">(2)</a> <a href="#ref-for-nsdecl">(3)</a>
    <li><a href="#ref-for-nsdecl">6.4. 
Attribute selectors and namespaces</a> <a href="#ref-for-nsdecl">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="invalid-selector">
   <b><a href="#invalid-selector">#invalid-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-invalid-selector">3.9. 
Invalid Selectors and Error Handling</a> <a href="#ref-for-invalid-selector①">(2)</a>
    <li><a href="#ref-for-invalid-selector②">5.3. 
Namespaces in Elemental Selectors</a>
    <li><a href="#ref-for-invalid-selector③">18. 
API Hooks</a>
    <li><a href="#ref-for-invalid-selector④">18.1. 
Parse A Selector</a> <a href="#ref-for-invalid-selector⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="matches-pseudo">
   <b><a href="#matches-pseudo">#matches-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-matches-pseudo">3.6.3. 
Pseudo-classing Pseudo-elements</a>
    <li><a href="#ref-for-matches-pseudo①">4.2. 
The Matches-Any Pseudo-class: :is()</a> <a href="#ref-for-matches-pseudo②">(2)</a> <a href="#ref-for-matches-pseudo③">(3)</a> <a href="#ref-for-matches-pseudo④">(4)</a> <a href="#ref-for-matches-pseudo⑤">(5)</a> <a href="#ref-for-matches-pseudo⑥">(6)</a> <a href="#ref-for-matches-pseudo⑦">(7)</a> <a href="#ref-for-matches-pseudo⑧">(8)</a>
    <li><a href="#ref-for-matches-pseudo⑨">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a> <a href="#ref-for-matches-pseudo①⓪">(2)</a>
    <li><a href="#ref-for-matches-pseudo①①">4.4. 
The Specificity-adjustment Pseudo-class: :where()</a> <a href="#ref-for-matches-pseudo①②">(2)</a>
    <li><a href="#ref-for-matches-pseudo①③">10.1. 
The Current-element Pseudo-class: :current</a>
    <li><a href="#ref-for-matches-pseudo①④">16. 
Calculating a selector’s specificity</a>
    <li><a href="#ref-for-matches-pseudo①⑤">19. 
Appendix A: Guidance on Mapping Source Documents &amp; Data to an Element Tree</a>
    <li><a href="#ref-for-matches-pseudo①⑥">21.1. 
Changes since the 2 February 2018 Working Draft</a> <a href="#ref-for-matches-pseudo①⑦">(2)</a>
    <li><a href="#ref-for-matches-pseudo①⑧">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selectordef-matches">
   <b><a href="#selectordef-matches">#selectordef-matches</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-matches">21.1. 
Changes since the 2 February 2018 Working Draft</a>
    <li><a href="#ref-for-selectordef-matches①">21.2. 
Changes since the 2 May 2013 Working Draft</a> <a href="#ref-for-selectordef-matches②">(2)</a>
    <li><a href="#ref-for-selectordef-matches③">21.3. 
Changes since the 23 August 2012 Working Draft</a> <a href="#ref-for-selectordef-matches④">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="negation-pseudo">
   <b><a href="#negation-pseudo">#negation-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-negation-pseudo">3.6.3. 
Pseudo-classing Pseudo-elements</a>
    <li><a href="#ref-for-negation-pseudo①">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a> <a href="#ref-for-negation-pseudo②">(2)</a> <a href="#ref-for-negation-pseudo③">(3)</a> <a href="#ref-for-negation-pseudo④">(4)</a> <a href="#ref-for-negation-pseudo⑤">(5)</a> <a href="#ref-for-negation-pseudo⑥">(6)</a>
    <li><a href="#ref-for-negation-pseudo⑦">9.4. 
The Focus-Indicated Pseudo-class: :focus-visible</a>
    <li><a href="#ref-for-negation-pseudo⑧">13.4.2. 
:nth-last-of-type() pseudo-class</a>
    <li><a href="#ref-for-negation-pseudo⑨">16. 
Calculating a selector’s specificity</a>
    <li><a href="#ref-for-negation-pseudo①⓪">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-negation-pseudo①①">21.3. 
Changes since the 23 August 2012 Working Draft</a>
    <li><a href="#ref-for-negation-pseudo①②">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="where-pseudo">
   <b><a href="#where-pseudo">#where-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-where-pseudo">4.4. 
The Specificity-adjustment Pseudo-class: :where()</a> <a href="#ref-for-where-pseudo①">(2)</a>
    <li><a href="#ref-for-where-pseudo②">16. 
Calculating a selector’s specificity</a> <a href="#ref-for-where-pseudo③">(2)</a>
    <li><a href="#ref-for-where-pseudo④">21.1. 
Changes since the 2 February 2018 Working Draft</a>
    <li><a href="#ref-for-where-pseudo⑤">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="has-pseudo">
   <b><a href="#has-pseudo">#has-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-has-pseudo">2.1. 
Live vs Snapshot Selector Profiles</a>
    <li><a href="#ref-for-has-pseudo①">4.5. 
The Relational Pseudo-class: :has()</a>
    <li><a href="#ref-for-has-pseudo②">16. 
Calculating a selector’s specificity</a>
    <li><a href="#ref-for-has-pseudo③">19. 
Appendix A: Guidance on Mapping Source Documents &amp; Data to an Element Tree</a>
    <li><a href="#ref-for-has-pseudo④">21.1. 
Changes since the 2 February 2018 Working Draft</a>
    <li><a href="#ref-for-has-pseudo⑤">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-has-pseudo⑥">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="type-selector">
   <b><a href="#type-selector">#type-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-type-selector">3.1. 
Structure and Terminology</a> <a href="#ref-for-type-selector①">(2)</a>
    <li><a href="#ref-for-type-selector②">3.5. 
Pseudo-classes</a>
    <li><a href="#ref-for-type-selector③">4.2. 
The Matches-Any Pseudo-class: :is()</a>
    <li><a href="#ref-for-type-selector④">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a>
    <li><a href="#ref-for-type-selector⑤">5.1. 
Type (tag name) selector</a>
    <li><a href="#ref-for-type-selector⑥">5.2. 
Universal selector </a> <a href="#ref-for-type-selector⑦">(2)</a> <a href="#ref-for-type-selector⑧">(3)</a>
    <li><a href="#ref-for-type-selector⑨">5.3. 
Namespaces in Elemental Selectors</a> <a href="#ref-for-type-selector①⓪">(2)</a> <a href="#ref-for-type-selector①①">(3)</a>
    <li><a href="#ref-for-type-selector①②">13.4.1. 
:nth-of-type() pseudo-class</a>
    <li><a href="#ref-for-type-selector①③">13.4.2. 
:nth-last-of-type() pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="universal-selector">
   <b><a href="#universal-selector">#universal-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-universal-selector">3.1. 
Structure and Terminology</a> <a href="#ref-for-universal-selector①">(2)</a>
    <li><a href="#ref-for-universal-selector②">3.5. 
Pseudo-classes</a>
    <li><a href="#ref-for-universal-selector③">3.6.2. 
Binding to the Document Tree</a>
    <li><a href="#ref-for-universal-selector④">4.2. 
The Matches-Any Pseudo-class: :is()</a>
    <li><a href="#ref-for-universal-selector⑤">4.3. 
The Negation (Matches-None) Pseudo-class: :not()</a>
    <li><a href="#ref-for-universal-selector⑥">5.2. 
Universal selector </a> <a href="#ref-for-universal-selector⑦">(2)</a> <a href="#ref-for-universal-selector⑧">(3)</a> <a href="#ref-for-universal-selector⑨">(4)</a> <a href="#ref-for-universal-selector①⓪">(5)</a>
    <li><a href="#ref-for-universal-selector①①">5.3. 
Namespaces in Elemental Selectors</a> <a href="#ref-for-universal-selector①②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="attribute-selector">
   <b><a href="#attribute-selector">#attribute-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-attribute-selector">3.1. 
Structure and Terminology</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="class-selector">
   <b><a href="#class-selector">#class-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-class-selector">3.1. 
Structure and Terminology</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="id-selector">
   <b><a href="#id-selector">#id-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-id-selector">3.1. 
Structure and Terminology</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dir-pseudo">
   <b><a href="#dir-pseudo">#dir-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dir-pseudo">7.1. 
The Directionality Pseudo-class: :dir()</a> <a href="#ref-for-dir-pseudo①">(2)</a> <a href="#ref-for-dir-pseudo②">(3)</a>
    <li><a href="#ref-for-dir-pseudo③">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="lang-pseudo">
   <b><a href="#lang-pseudo">#lang-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-lang-pseudo">3.2. 
Data Model</a>
    <li><a href="#ref-for-lang-pseudo①">3.5. 
Pseudo-classes</a>
    <li><a href="#ref-for-lang-pseudo②">3.7. 
Characters and case sensitivity</a>
    <li><a href="#ref-for-lang-pseudo③">7.2. 
The Language Pseudo-class: :lang()</a> <a href="#ref-for-lang-pseudo④">(2)</a>
    <li><a href="#ref-for-lang-pseudo⑤">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-lang-pseudo⑥">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="language-range">
   <b><a href="#language-range">#language-range</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-language-range">3.7. 
Characters and case sensitivity</a>
    <li><a href="#ref-for-language-range①">7.2. 
The Language Pseudo-class: :lang()</a> <a href="#ref-for-language-range②">(2)</a> <a href="#ref-for-language-range③">(3)</a> <a href="#ref-for-language-range④">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="any-link-pseudo">
   <b><a href="#any-link-pseudo">#any-link-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-any-link-pseudo">8.1. 
The Hyperlink Pseudo-class: :any-link</a>
    <li><a href="#ref-for-any-link-pseudo①">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="link-pseudo">
   <b><a href="#link-pseudo">#link-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-link-pseudo">8.1. 
The Hyperlink Pseudo-class: :any-link</a>
    <li><a href="#ref-for-link-pseudo①">8.2. 
The Link History Pseudo-classes: :link and :visited</a> <a href="#ref-for-link-pseudo②">(2)</a> <a href="#ref-for-link-pseudo③">(3)</a>
    <li><a href="#ref-for-link-pseudo④">9.2. 
The Activation Pseudo-class: :active</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="visited-pseudo">
   <b><a href="#visited-pseudo">#visited-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-visited-pseudo">8.1. 
The Hyperlink Pseudo-class: :any-link</a>
    <li><a href="#ref-for-visited-pseudo①">8.2. 
The Link History Pseudo-classes: :link and :visited</a> <a href="#ref-for-visited-pseudo②">(2)</a>
    <li><a href="#ref-for-visited-pseudo③">9.2. 
The Activation Pseudo-class: :active</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="local-link-pseudo">
   <b><a href="#local-link-pseudo">#local-link-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-local-link-pseudo">8.3. 
The Local Link Pseudo-class: :local-link</a> <a href="#ref-for-local-link-pseudo①">(2)</a>
    <li><a href="#ref-for-local-link-pseudo②">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="target-pseudo">
   <b><a href="#target-pseudo">#target-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-target-pseudo">8.3. 
The Local Link Pseudo-class: :local-link</a>
    <li><a href="#ref-for-target-pseudo①">8.4. 
The Target Pseudo-class: :target</a> <a href="#ref-for-target-pseudo②">(2)</a>
    <li><a href="#ref-for-target-pseudo③">8.5. 
The Target Container Pseudo-class: :target-within</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="target-within-pseudo">
   <b><a href="#target-within-pseudo">#target-within-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-target-within-pseudo">8.3. 
The Local Link Pseudo-class: :local-link</a>
    <li><a href="#ref-for-target-within-pseudo①">8.5. 
The Target Container Pseudo-class: :target-within</a> <a href="#ref-for-target-within-pseudo②">(2)</a>
    <li><a href="#ref-for-target-within-pseudo③">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-target-within-pseudo④">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="scope-element">
   <b><a href="#scope-element">#scope-element</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-scope-element">2. 
Selectors Overview</a>
    <li><a href="#ref-for-scope-element①">3.3. 
Scoped Selectors</a> <a href="#ref-for-scope-element②">(2)</a>
    <li><a href="#ref-for-scope-element③">3.4. 
Relative Selectors</a>
    <li><a href="#ref-for-scope-element④">3.4.1. 
Absolutizing a Relative Selector</a>
    <li><a href="#ref-for-scope-element⑤">4.5. 
The Relational Pseudo-class: :has()</a>
    <li><a href="#ref-for-scope-element⑥">8.6. 
The Reference Element Pseudo-class: :scope</a> <a href="#ref-for-scope-element⑦">(2)</a> <a href="#ref-for-scope-element⑧">(3)</a>
    <li><a href="#ref-for-scope-element⑨">18.2. 
Parse A Relative Selector</a> <a href="#ref-for-scope-element①⓪">(2)</a>
    <li><a href="#ref-for-scope-element①①">18.3. 
Match a Selector Against an Element</a> <a href="#ref-for-scope-element①②">(2)</a>
    <li><a href="#ref-for-scope-element①③">18.5. 
Match a Selector Against a Tree</a> <a href="#ref-for-scope-element①④">(2)</a> <a href="#ref-for-scope-element①⑤">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="scope-pseudo">
   <b><a href="#scope-pseudo">#scope-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-scope-pseudo">3.4. 
Relative Selectors</a> <a href="#ref-for-scope-pseudo①">(2)</a> <a href="#ref-for-scope-pseudo②">(3)</a>
    <li><a href="#ref-for-scope-pseudo③">3.4.1. 
Absolutizing a Relative Selector</a> <a href="#ref-for-scope-pseudo④">(2)</a> <a href="#ref-for-scope-pseudo⑤">(3)</a>
    <li><a href="#ref-for-scope-pseudo⑥">8.6. 
The Reference Element Pseudo-class: :scope</a> <a href="#ref-for-scope-pseudo⑦">(2)</a>
    <li><a href="#ref-for-scope-pseudo⑧">18.3. 
Match a Selector Against an Element</a> <a href="#ref-for-scope-pseudo⑨">(2)</a>
    <li><a href="#ref-for-scope-pseudo①⓪">18.5. 
Match a Selector Against a Tree</a>
    <li><a href="#ref-for-scope-pseudo①①">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="user-action-pseudo-class">
   <b><a href="#user-action-pseudo-class">#user-action-pseudo-class</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-user-action-pseudo-class">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="hover-pseudo">
   <b><a href="#hover-pseudo">#hover-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-hover-pseudo">3.6.3. 
Pseudo-classing Pseudo-elements</a>
    <li><a href="#ref-for-hover-pseudo①">9.1. 
The Pointer Hover Pseudo-class: :hover</a> <a href="#ref-for-hover-pseudo②">(2)</a> <a href="#ref-for-hover-pseudo③">(3)</a> <a href="#ref-for-hover-pseudo④">(4)</a> <a href="#ref-for-hover-pseudo⑤">(5)</a> <a href="#ref-for-hover-pseudo⑥">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="active-pseudo">
   <b><a href="#active-pseudo">#active-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-active-pseudo">9.2. 
The Activation Pseudo-class: :active</a> <a href="#ref-for-active-pseudo①">(2)</a> <a href="#ref-for-active-pseudo②">(3)</a> <a href="#ref-for-active-pseudo③">(4)</a> <a href="#ref-for-active-pseudo④">(5)</a> <a href="#ref-for-active-pseudo⑤">(6)</a> <a href="#ref-for-active-pseudo⑥">(7)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="focus-pseudo">
   <b><a href="#focus-pseudo">#focus-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-focus-pseudo">3.6.3. 
Pseudo-classing Pseudo-elements</a> <a href="#ref-for-focus-pseudo①">(2)</a>
    <li><a href="#ref-for-focus-pseudo②">9.3. 
The Input Focus Pseudo-class: :focus</a> <a href="#ref-for-focus-pseudo③">(2)</a> <a href="#ref-for-focus-pseudo④">(3)</a> <a href="#ref-for-focus-pseudo⑤">(4)</a> <a href="#ref-for-focus-pseudo⑥">(5)</a>
    <li><a href="#ref-for-focus-pseudo⑦">9.4. 
The Focus-Indicated Pseudo-class: :focus-visible</a> <a href="#ref-for-focus-pseudo⑧">(2)</a> <a href="#ref-for-focus-pseudo⑨">(3)</a>
    <li><a href="#ref-for-focus-pseudo①⓪">9.5. 
The Focus Container Pseudo-class: :focus-within</a> <a href="#ref-for-focus-pseudo①①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="focus-visible-pseudo">
   <b><a href="#focus-visible-pseudo">#focus-visible-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-focus-visible-pseudo">9.4. 
The Focus-Indicated Pseudo-class: :focus-visible</a> <a href="#ref-for-focus-visible-pseudo①">(2)</a> <a href="#ref-for-focus-visible-pseudo②">(3)</a> <a href="#ref-for-focus-visible-pseudo③">(4)</a> <a href="#ref-for-focus-visible-pseudo④">(5)</a> <a href="#ref-for-focus-visible-pseudo⑤">(6)</a> <a href="#ref-for-focus-visible-pseudo⑥">(7)</a> <a href="#ref-for-focus-visible-pseudo⑦">(8)</a> <a href="#ref-for-focus-visible-pseudo⑧">(9)</a> <a href="#ref-for-focus-visible-pseudo⑨">(10)</a> <a href="#ref-for-focus-visible-pseudo①⓪">(11)</a> <a href="#ref-for-focus-visible-pseudo①①">(12)</a> <a href="#ref-for-focus-visible-pseudo①②">(13)</a> <a href="#ref-for-focus-visible-pseudo①③">(14)</a> <a href="#ref-for-focus-visible-pseudo①④">(15)</a> <a href="#ref-for-focus-visible-pseudo①⑤">(16)</a> <a href="#ref-for-focus-visible-pseudo①⑥">(17)</a>
    <li><a href="#ref-for-focus-visible-pseudo①⑦">21.1. 
Changes since the 2 February 2018 Working Draft</a>
    <li><a href="#ref-for-focus-visible-pseudo①⑧">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-focus-visible-pseudo①⑨">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="focus-within-pseudo">
   <b><a href="#focus-within-pseudo">#focus-within-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-focus-within-pseudo">9.3. 
The Input Focus Pseudo-class: :focus</a>
    <li><a href="#ref-for-focus-within-pseudo①">9.5. 
The Focus Container Pseudo-class: :focus-within</a>
    <li><a href="#ref-for-focus-within-pseudo②">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-focus-within-pseudo③">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="current-pseudo">
   <b><a href="#current-pseudo">#current-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-current-pseudo">2. 
Selectors Overview</a>
    <li><a href="#ref-for-current-pseudo①">10. 
Time-dimensional Pseudo-classes</a> <a href="#ref-for-current-pseudo②">(2)</a> <a href="#ref-for-current-pseudo③">(3)</a>
    <li><a href="#ref-for-current-pseudo④">10.1. 
The Current-element Pseudo-class: :current</a> <a href="#ref-for-current-pseudo⑤">(2)</a> <a href="#ref-for-current-pseudo⑥">(3)</a> <a href="#ref-for-current-pseudo⑦">(4)</a>
    <li><a href="#ref-for-current-pseudo⑧">10.2. 
The Past-element Pseudo-class: :past</a> <a href="#ref-for-current-pseudo⑨">(2)</a>
    <li><a href="#ref-for-current-pseudo①⓪">10.3. 
The Future-element Pseudo-class: :future</a> <a href="#ref-for-current-pseudo①①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="past-pseudo">
   <b><a href="#past-pseudo">#past-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-past-pseudo">10. 
Time-dimensional Pseudo-classes</a> <a href="#ref-for-past-pseudo①">(2)</a> <a href="#ref-for-past-pseudo②">(3)</a>
    <li><a href="#ref-for-past-pseudo③">10.2. 
The Past-element Pseudo-class: :past</a> <a href="#ref-for-past-pseudo④">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="future-pseudo">
   <b><a href="#future-pseudo">#future-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-future-pseudo">10. 
Time-dimensional Pseudo-classes</a> <a href="#ref-for-future-pseudo①">(2)</a> <a href="#ref-for-future-pseudo②">(3)</a>
    <li><a href="#ref-for-future-pseudo③">10.3. 
The Future-element Pseudo-class: :future</a> <a href="#ref-for-future-pseudo④">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selectordef-playing">
   <b><a href="#selectordef-playing">#selectordef-playing</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-playing">11.1. 
Video/Audio Play State: the :playing and :paused pseudo-classes</a>
    <li><a href="#ref-for-selectordef-playing①">21.2. 
Changes since the 2 May 2013 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="selectordef-paused">
   <b><a href="#selectordef-paused">#selectordef-paused</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-selectordef-paused">11.1. 
Video/Audio Play State: the :playing and :paused pseudo-classes</a>
    <li><a href="#ref-for-selectordef-paused①">21.2. 
Changes since the 2 May 2013 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="enabled-pseudo">
   <b><a href="#enabled-pseudo">#enabled-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-enabled-pseudo">12.1.1. 
The :enabled and :disabled Pseudo-classes</a> <a href="#ref-for-enabled-pseudo①">(2)</a> <a href="#ref-for-enabled-pseudo②">(3)</a> <a href="#ref-for-enabled-pseudo③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="disabled-pseudo">
   <b><a href="#disabled-pseudo">#disabled-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-disabled-pseudo">12.1.1. 
The :enabled and :disabled Pseudo-classes</a> <a href="#ref-for-disabled-pseudo①">(2)</a> <a href="#ref-for-disabled-pseudo②">(3)</a> <a href="#ref-for-disabled-pseudo③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="read-write-pseudo">
   <b><a href="#read-write-pseudo">#read-write-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-read-write-pseudo①">12.1.2. 
The Mutability Pseudo-classes: :read-only and :read-write</a> <a href="#ref-for-read-write-pseudo②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="read-only-pseudo">
   <b><a href="#read-only-pseudo">#read-only-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-read-only-pseudo">12.1.2. 
The Mutability Pseudo-classes: :read-only and :read-write</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="placeholder-shown-pseudo">
   <b><a href="#placeholder-shown-pseudo">#placeholder-shown-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-placeholder-shown-pseudo">12.1.3. 
The Placeholder-shown Pseudo-class: :placeholder-shown</a> <a href="#ref-for-placeholder-shown-pseudo①">(2)</a>
    <li><a href="#ref-for-placeholder-shown-pseudo②">21.3. 
Changes since the 23 August 2012 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="default-pseudo">
   <b><a href="#default-pseudo">#default-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-default-pseudo">12.1.4. 
The Default-option Pseudo-class: :default</a> <a href="#ref-for-default-pseudo①">(2)</a> <a href="#ref-for-default-pseudo②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="checked-pseudo">
   <b><a href="#checked-pseudo">#checked-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-checked-pseudo">12.2.1. 
The Selected-option Pseudo-class: :checked</a> <a href="#ref-for-checked-pseudo①">(2)</a> <a href="#ref-for-checked-pseudo②">(3)</a>
    <li><a href="#ref-for-checked-pseudo③">12.2.2. 
The Indeterminate-value Pseudo-class: :indeterminate</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="indetermine-pseudo">
   <b><a href="#indetermine-pseudo">#indetermine-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-indetermine-pseudo">12.2.2. 
The Indeterminate-value Pseudo-class: :indeterminate</a> <a href="#ref-for-indetermine-pseudo①">(2)</a> <a href="#ref-for-indetermine-pseudo②">(3)</a> <a href="#ref-for-indetermine-pseudo③">(4)</a>
    <li><a href="#ref-for-indetermine-pseudo④">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="blank-pseudo">
   <b><a href="#blank-pseudo">#blank-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-blank-pseudo">12.3.1. 
The Empty-Value Pseudo-class: :blank</a> <a href="#ref-for-blank-pseudo①">(2)</a>
    <li><a href="#ref-for-blank-pseudo②">21.1. 
Changes since the 2 February 2018 Working Draft</a>
    <li><a href="#ref-for-blank-pseudo③">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="valid-pseudo">
   <b><a href="#valid-pseudo">#valid-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-valid-pseudo">3.5. 
Pseudo-classes</a>
    <li><a href="#ref-for-valid-pseudo①">12.3.2. 
The Validity Pseudo-classes: :valid and :invalid</a> <a href="#ref-for-valid-pseudo②">(2)</a> <a href="#ref-for-valid-pseudo③">(3)</a> <a href="#ref-for-valid-pseudo④">(4)</a>
    <li><a href="#ref-for-valid-pseudo⑤">12.3.5. 
The User-interaction Pseudo-class: :user-invalid</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="invalid-pseudo">
   <b><a href="#invalid-pseudo">#invalid-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-invalid-pseudo">12.3.2. 
The Validity Pseudo-classes: :valid and :invalid</a> <a href="#ref-for-invalid-pseudo①">(2)</a> <a href="#ref-for-invalid-pseudo②">(3)</a>
    <li><a href="#ref-for-invalid-pseudo③">12.3.5. 
The User-interaction Pseudo-class: :user-invalid</a> <a href="#ref-for-invalid-pseudo④">(2)</a> <a href="#ref-for-invalid-pseudo⑤">(3)</a> <a href="#ref-for-invalid-pseudo⑥">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="in-range-pseudo">
   <b><a href="#in-range-pseudo">#in-range-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-in-range-pseudo">12.3.3. 
The Range Pseudo-classes: :in-range and :out-of-range</a> <a href="#ref-for-in-range-pseudo①">(2)</a> <a href="#ref-for-in-range-pseudo②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="out-of-range-pseudo">
   <b><a href="#out-of-range-pseudo">#out-of-range-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-out-of-range-pseudo">12.3.3. 
The Range Pseudo-classes: :in-range and :out-of-range</a> <a href="#ref-for-out-of-range-pseudo①">(2)</a> <a href="#ref-for-out-of-range-pseudo②">(3)</a>
    <li><a href="#ref-for-out-of-range-pseudo③">12.3.5. 
The User-interaction Pseudo-class: :user-invalid</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="required-pseudo">
   <b><a href="#required-pseudo">#required-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-required-pseudo">12.3.4. 
The Optionality Pseudo-classes: :required and :optional</a>
    <li><a href="#ref-for-required-pseudo①">12.3.5. 
The User-interaction Pseudo-class: :user-invalid</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="optional-pseudo">
   <b><a href="#optional-pseudo">#optional-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-optional-pseudo">12.3.4. 
The Optionality Pseudo-classes: :required and :optional</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="user-invalid-pseudo">
   <b><a href="#user-invalid-pseudo">#user-invalid-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-user-invalid-pseudo">12.3.5. 
The User-interaction Pseudo-class: :user-invalid</a> <a href="#ref-for-user-invalid-pseudo①">(2)</a> <a href="#ref-for-user-invalid-pseudo②">(3)</a> <a href="#ref-for-user-invalid-pseudo③">(4)</a>
    <li><a href="#ref-for-user-invalid-pseudo④">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-user-invalid-pseudo⑤">21.4. 
Changes since the 29 September 2011 Working Draft</a>
    <li><a href="#ref-for-user-invalid-pseudo⑥">21.5. 
Changes Since Level 3</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="structural-pseudo-classes">
   <b><a href="#structural-pseudo-classes">#structural-pseudo-classes</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-structural-pseudo-classes">3.6. Pseudo-elements</a>
    <li><a href="#ref-for-structural-pseudo-classes①">13. 
Tree-Structural pseudo-classes</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="root-pseudo">
   <b><a href="#root-pseudo">#root-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-root-pseudo">8.6. 
The Reference Element Pseudo-class: :scope</a>
    <li><a href="#ref-for-root-pseudo①">13.1. 
:root pseudo-class</a> <a href="#ref-for-root-pseudo②">(2)</a>
    <li><a href="#ref-for-root-pseudo③">19. 
Appendix A: Guidance on Mapping Source Documents &amp; Data to an Element Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="empty-pseudo">
   <b><a href="#empty-pseudo">#empty-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-empty-pseudo">13.2. 
:empty pseudo-class</a> <a href="#ref-for-empty-pseudo①">(2)</a>
    <li><a href="#ref-for-empty-pseudo②">21.1. 
Changes since the 2 February 2018 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="nth-child-pseudo">
   <b><a href="#nth-child-pseudo">#nth-child-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-nth-child-pseudo">13.3.1. 
:nth-child() pseudo-class</a> <a href="#ref-for-nth-child-pseudo①">(2)</a>
    <li><a href="#ref-for-nth-child-pseudo②">13.3.2. 
:nth-last-child() pseudo-class</a>
    <li><a href="#ref-for-nth-child-pseudo③">13.4.1. 
:nth-of-type() pseudo-class</a>
    <li><a href="#ref-for-nth-child-pseudo④">16. 
Calculating a selector’s specificity</a>
    <li><a href="#ref-for-nth-child-pseudo⑤">19. 
Appendix A: Guidance on Mapping Source Documents &amp; Data to an Element Tree</a>
    <li><a href="#ref-for-nth-child-pseudo⑥">21.1. 
Changes since the 2 February 2018 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="nth-last-child-pseudo">
   <b><a href="#nth-last-child-pseudo">#nth-last-child-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-nth-last-child-pseudo">13.3.2. 
:nth-last-child() pseudo-class</a> <a href="#ref-for-nth-last-child-pseudo①">(2)</a>
    <li><a href="#ref-for-nth-last-child-pseudo②">16. 
Calculating a selector’s specificity</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="first-child-pseudo">
   <b><a href="#first-child-pseudo">#first-child-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-first-child-pseudo">13.3.3. 
:first-child pseudo-class</a>
    <li><a href="#ref-for-first-child-pseudo①">14.2. 
Child combinator (>)</a>
    <li><a href="#ref-for-first-child-pseudo②">19. 
Appendix A: Guidance on Mapping Source Documents &amp; Data to an Element Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="last-child-pseudo">
   <b><a href="#last-child-pseudo">#last-child-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-last-child-pseudo">13.3.4. 
:last-child pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="only-child-pseudo">
   <b><a href="#only-child-pseudo">#only-child-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-only-child-pseudo">13.3.5. 
:only-child pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="nth-of-type-pseudo">
   <b><a href="#nth-of-type-pseudo">#nth-of-type-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-nth-of-type-pseudo">13.4.1. 
:nth-of-type() pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="nth-last-of-type-pseudo">
   <b><a href="#nth-last-of-type-pseudo">#nth-last-of-type-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-nth-last-of-type-pseudo">13.4.2. 
:nth-last-of-type() pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="first-of-type-pseudo">
   <b><a href="#first-of-type-pseudo">#first-of-type-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-first-of-type-pseudo">13.4.3. 
:first-of-type pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="last-of-type-pseudo">
   <b><a href="#last-of-type-pseudo">#last-of-type-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-last-of-type-pseudo">13.4.4. 
:last-of-type pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="only-of-type-pseudo">
   <b><a href="#only-of-type-pseudo">#only-of-type-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-only-of-type-pseudo">13.4.5. 
:only-of-type pseudo-class</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="descendant-combinator">
   <b><a href="#descendant-combinator">#descendant-combinator</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-descendant-combinator">3.1. 
Structure and Terminology</a> <a href="#ref-for-descendant-combinator①">(2)</a>
    <li><a href="#ref-for-descendant-combinator②">3.4.1. 
Absolutizing a Relative Selector</a> <a href="#ref-for-descendant-combinator③">(2)</a>
    <li><a href="#ref-for-descendant-combinator④">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="child-combinator">
   <b><a href="#child-combinator">#child-combinator</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-child-combinator">3.1. 
Structure and Terminology</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="next-sibling-combinator">
   <b><a href="#next-sibling-combinator">#next-sibling-combinator</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-next-sibling-combinator">3.1. 
Structure and Terminology</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="subsequent-sibling-combinator">
   <b><a href="#subsequent-sibling-combinator">#subsequent-sibling-combinator</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-subsequent-sibling-combinator">3.1. 
Structure and Terminology</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="column-combinator">
   <b><a href="#column-combinator">#column-combinator</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-column-combinator">15. 
Grid-Structural Selectors</a>
    <li><a href="#ref-for-column-combinator①">21.4. 
Changes since the 29 September 2011 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="nth-col-pseudo">
   <b><a href="#nth-col-pseudo">#nth-col-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-nth-col-pseudo">15. 
Grid-Structural Selectors</a>
    <li><a href="#ref-for-nth-col-pseudo①">15.2. 
:nth-col() pseudo-class</a>
    <li><a href="#ref-for-nth-col-pseudo②">21.2. 
Changes since the 2 May 2013 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="nth-last-col-pseudo">
   <b><a href="#nth-last-col-pseudo">#nth-last-col-pseudo</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-nth-last-col-pseudo">15. 
Grid-Structural Selectors</a>
    <li><a href="#ref-for-nth-last-col-pseudo①">15.3. 
:nth-last-col() pseudo-class</a>
    <li><a href="#ref-for-nth-last-col-pseudo②">21.2. 
Changes since the 2 May 2013 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="specificity">
   <b><a href="#specificity">#specificity</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-specificity">21.2. 
Changes since the 2 May 2013 Working Draft</a>
    <li><a href="#ref-for-specificity①">21.3. 
Changes since the 23 August 2012 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-selector-list">
   <b><a href="#typedef-selector-list">#typedef-selector-list</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-selector-list">18.1. 
Parse A Selector</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-complex-selector-list">
   <b><a href="#typedef-complex-selector-list">#typedef-complex-selector-list</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-complex-selector-list">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-relative-selector-list">
   <b><a href="#typedef-relative-selector-list">#typedef-relative-selector-list</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-relative-selector-list">18.2. 
Parse A Relative Selector</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-complex-selector">
   <b><a href="#typedef-complex-selector">#typedef-complex-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-complex-selector">3.1. 
Structure and Terminology</a>
    <li><a href="#ref-for-typedef-complex-selector①">17. 
Grammar</a> <a href="#ref-for-typedef-complex-selector②">(2)</a> <a href="#ref-for-typedef-complex-selector③">(3)</a> <a href="#ref-for-typedef-complex-selector④">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-relative-selector">
   <b><a href="#typedef-relative-selector">#typedef-relative-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-relative-selector">3.4. 
Relative Selectors</a>
    <li><a href="#ref-for-typedef-relative-selector①">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-compound-selector">
   <b><a href="#typedef-compound-selector">#typedef-compound-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-compound-selector">3.1. 
Structure and Terminology</a>
    <li><a href="#ref-for-typedef-compound-selector①">17. 
Grammar</a> <a href="#ref-for-typedef-compound-selector②">(2)</a> <a href="#ref-for-typedef-compound-selector③">(3)</a> <a href="#ref-for-typedef-compound-selector④">(4)</a> <a href="#ref-for-typedef-compound-selector⑤">(5)</a> <a href="#ref-for-typedef-compound-selector⑥">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-simple-selector">
   <b><a href="#typedef-simple-selector">#typedef-simple-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-simple-selector">3.1. 
Structure and Terminology</a>
    <li><a href="#ref-for-typedef-simple-selector①">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-combinator">
   <b><a href="#typedef-combinator">#typedef-combinator</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-combinator">17. 
Grammar</a> <a href="#ref-for-typedef-combinator①">(2)</a> <a href="#ref-for-typedef-combinator②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-type-selector">
   <b><a href="#typedef-type-selector">#typedef-type-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-type-selector">17. 
Grammar</a> <a href="#ref-for-typedef-type-selector①">(2)</a> <a href="#ref-for-typedef-type-selector②">(3)</a> <a href="#ref-for-typedef-type-selector③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-ns-prefix">
   <b><a href="#typedef-ns-prefix">#typedef-ns-prefix</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-ns-prefix">17. 
Grammar</a> <a href="#ref-for-typedef-ns-prefix①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-wq-name">
   <b><a href="#typedef-wq-name">#typedef-wq-name</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-wq-name">17. 
Grammar</a> <a href="#ref-for-typedef-wq-name①">(2)</a> <a href="#ref-for-typedef-wq-name②">(3)</a> <a href="#ref-for-typedef-wq-name③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-subclass-selector">
   <b><a href="#typedef-subclass-selector">#typedef-subclass-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-subclass-selector">17. 
Grammar</a> <a href="#ref-for-typedef-subclass-selector①">(2)</a> <a href="#ref-for-typedef-subclass-selector②">(3)</a> <a href="#ref-for-typedef-subclass-selector③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-id-selector">
   <b><a href="#typedef-id-selector">#typedef-id-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-id-selector">17. 
Grammar</a> <a href="#ref-for-typedef-id-selector①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-class-selector">
   <b><a href="#typedef-class-selector">#typedef-class-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-class-selector">17. 
Grammar</a> <a href="#ref-for-typedef-class-selector①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-attribute-selector">
   <b><a href="#typedef-attribute-selector">#typedef-attribute-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-attribute-selector">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-attr-matcher">
   <b><a href="#typedef-attr-matcher">#typedef-attr-matcher</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-attr-matcher">17. 
Grammar</a> <a href="#ref-for-typedef-attr-matcher①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-attr-modifier">
   <b><a href="#typedef-attr-modifier">#typedef-attr-modifier</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-attr-modifier">17. 
Grammar</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-pseudo-class-selector">
   <b><a href="#typedef-pseudo-class-selector">#typedef-pseudo-class-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-pseudo-class-selector">17. 
Grammar</a> <a href="#ref-for-typedef-pseudo-class-selector①">(2)</a> <a href="#ref-for-typedef-pseudo-class-selector②">(3)</a> <a href="#ref-for-typedef-pseudo-class-selector③">(4)</a> <a href="#ref-for-typedef-pseudo-class-selector④">(5)</a> <a href="#ref-for-typedef-pseudo-class-selector⑤">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="typedef-pseudo-element-selector">
   <b><a href="#typedef-pseudo-element-selector">#typedef-pseudo-element-selector</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-typedef-pseudo-element-selector">17. 
Grammar</a> <a href="#ref-for-typedef-pseudo-element-selector①">(2)</a> <a href="#ref-for-typedef-pseudo-element-selector②">(3)</a> <a href="#ref-for-typedef-pseudo-element-selector③">(4)</a> <a href="#ref-for-typedef-pseudo-element-selector④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="match-a-selector-against-an-element">
   <b><a href="#match-a-selector-against-an-element">#match-a-selector-against-an-element</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-match-a-selector-against-an-element">18.4. 
Match a Selector Against a Pseudo-element</a>
    <li><a href="#ref-for-match-a-selector-against-an-element①">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="match-a-complex-selector-against-an-element">
   <b><a href="#match-a-complex-selector-against-an-element">#match-a-complex-selector-against-an-element</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-match-a-complex-selector-against-an-element">18.4. 
Match a Selector Against a Pseudo-element</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="match-a-selector-against-a-pseudo-element">
   <b><a href="#match-a-selector-against-a-pseudo-element">#match-a-selector-against-a-pseudo-element</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-match-a-selector-against-a-pseudo-element">18.5. 
Match a Selector Against a Tree</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="match-a-selector-against-a-tree">
   <b><a href="#match-a-selector-against-a-tree">#match-a-selector-against-a-tree</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-match-a-selector-against-a-tree">21.2. 
Changes since the 2 May 2013 Working Draft</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="unknown--webkit--pseudo-elements">
   <b><a href="#unknown--webkit--pseudo-elements">#unknown--webkit--pseudo-elements</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-unknown--webkit--pseudo-elements">20. 
Appendix B: Obsolete but Required Parsing Quirks for Web Compat</a>
   </ul>
  </aside>
<script>/* script-var-click-highlighting */

    document.addEventListener("click", e=>{
        if(e.target.nodeName == "VAR") {
            highlightSameAlgoVars(e.target);
        }
    });
    {
        const indexCounts = new Map();
        const indexNames = new Map();
        function highlightSameAlgoVars(v) {
            // Find the algorithm container.
            let algoContainer = null;
            let searchEl = v;
            while(algoContainer == null && searchEl != document.body) {
                searchEl = searchEl.parentNode;
                if(searchEl.hasAttribute("data-algorithm")) {
                    algoContainer = searchEl;
                }
            }

            // Not highlighting document-global vars,
            // too likely to be unrelated.
            if(algoContainer == null) return;

            const algoName = algoContainer.getAttribute("data-algorithm");
            const varName = getVarName(v);
            const addClass = !v.classList.contains("selected");
            let highlightClass = null;
            if(addClass) {
                const index = chooseHighlightIndex(algoName, varName);
                indexCounts.get(algoName)[index] += 1;
                indexNames.set(algoName+"///"+varName, index);
                highlightClass = nameFromIndex(index);
            } else {
                const index = previousHighlightIndex(algoName, varName);
                indexCounts.get(algoName)[index] -= 1;
                highlightClass = nameFromIndex(index);
            }

            // Find all same-name vars, and toggle their class appropriately.
            for(const el of algoContainer.querySelectorAll("var")) {
                if(getVarName(el) == varName) {
                    el.classList.toggle("selected", addClass);
                    el.classList.toggle(highlightClass, addClass);
                }
            }
        }
        function getVarName(el) {
            return el.textContent.replace(/(\s| )+/, " ").trim();
        }
        function chooseHighlightIndex(algoName, varName) {
            let indexes = null;
            if(indexCounts.has(algoName)) {
                indexes = indexCounts.get(algoName);
            } else {
                // 7 classes right now
                indexes = [0,0,0,0,0,0,0];
                indexCounts.set(algoName, indexes);
            }

            // If the element was recently unclicked,
            // *and* that color is still unclaimed,
            // give it back the same color.
            const lastIndex = previousHighlightIndex(algoName, varName);
            if(indexes[lastIndex] === 0) return lastIndex;

            // Find the earliest index with the lowest count.
            const minCount = Math.min.apply(null, indexes);
            let index = null;
            for(var i = 0; i < indexes.length; i++) {
                if(indexes[i] == minCount) {
                    return i;
                }
            }
        }
        function previousHighlightIndex(algoName, varName) {
            return indexNames.get(algoName+"///"+varName);
        }
        function nameFromIndex(index) {
            return "selected" + index;
        }
    }
    </script>
<script>/* script-dfn-panel */

document.body.addEventListener("click", function(e) {
    var queryAll = function(sel) { return [].slice.call(document.querySelectorAll(sel)); }
    // Find the dfn element or panel, if any, that was clicked on.
    var el = e.target;
    var target;
    var hitALink = false;
    while(el.parentElement) {
        if(el.tagName == "A") {
            // Clicking on a link in a <dfn> shouldn't summon the panel
            hitALink = true;
        }
        if(el.classList.contains("dfn-paneled")) {
            target = "dfn";
            break;
        }
        if(el.classList.contains("dfn-panel")) {
            target = "dfn-panel";
            break;
        }
        el = el.parentElement;
    }
    if(target != "dfn-panel") {
        // Turn off any currently "on" or "activated" panels.
        queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(function(el){
            el.classList.remove("on");
            el.classList.remove("activated");
        });
    }
    if(target == "dfn" && !hitALink) {
        // open the panel
        var dfnPanel = document.querySelector(".dfn-panel[data-for='" + el.id + "']");
        if(dfnPanel) {
            dfnPanel.classList.add("on");
            var rect = el.getBoundingClientRect();
            dfnPanel.style.left = window.scrollX + rect.right + 5 + "px";
            dfnPanel.style.top = window.scrollY + rect.top + "px";
            var panelRect = dfnPanel.getBoundingClientRect();
            var panelWidth = panelRect.right - panelRect.left;
            if(panelRect.right > document.body.scrollWidth && (rect.left - (panelWidth + 5)) > 0) {
                // Reposition, because the panel is overflowing
                dfnPanel.style.left = window.scrollX + rect.left - (panelWidth + 5) + "px";
            }
        } else {
            console.log("Couldn't find .dfn-panel[data-for='" + el.id + "']");
        }
    } else if(target == "dfn-panel") {
        // Switch it to "activated" state, which pins it.
        el.classList.add("activated");
        el.style.left = null;
        el.style.top = null;
    }

});
</script>